How to make this command unable to use for certain levels
#1

I have a question here How do I make it so it wont let multiple levels not able to use the cmd using dcmd because right now it lets all levels able to setadmin.Heres code

dcmd_setadmin(playerid, params[])
{
if(pInfo[playerid][pAdmin] == 4) return SystemMessage(playerid, "You are not Administrator.");
new alevel, str[128];
if(sscanf(params, "ud", giveplayerid, alevel)) return SystemMessage(playerid, "Correct usage: '/setadmin [playername] [level]'");
if(!IsPlayerConnected(giveplayerid)) return SystemMessage(playerid, "This player is not active.");
if(alevel < 0) return SystemMessage(playerid, "Invalid level!");
GetName(giveplayerid, playername);
GetName(playerid, adminname);
pInfo[giveplayerid][pAdmin] = alevel;
format(str, sizeof(str), "Administrator %s (%d) has set your admin level to %d", adminname, playerid, alevel);
SystemMessage(giveplayerid, str);
format(str, sizeof(str), "You have set %s (%d) admin level to %d", playername, giveplayerid, alevel);
SystemMessage(playerid, str);
return 1;
}
Reply
#2

My guess is that every admin level except 4 can use this command. If 4 is your highest admin level, then you should put:

pawn Код:
if(pInfo[playerid][pAdmin] != 4) return SystemMessage(playerid, "You are not Administrator.");
Otherwise:

pawn Код:
if(pInfo[playerid][pAdmin] <= 4) return SystemMessage(playerid, "You are not Administrator.");
Reply
#3

Quote:
Originally Posted by Kevin Fallow / KevKo
My guess is that every admin level except 4 can use this command. If 4 is your highest admin level, then you should put:

pawn Код:
if(pInfo[playerid][pAdmin] != 4) return SystemMessage(playerid, "You are not Administrator.");
Otherwise:

pawn Код:
if(pInfo[playerid][pAdmin] <= 4) return SystemMessage(playerid, "You are not Administrator.");
Ok thx that fixed but what if I want to let level 3 and level 2 to do the command? without letting level 0 do it
Reply
#4

Then use that
pawn Код:
if(pInfo[playerid][pAdmin] >= 4) return SystemMessage(playerid, "You are not Administrator.");
Reply
#5

Quote:
Originally Posted by Bomba' Xtreme'Stuntage
Then use that
pawn Код:
if(pInfo[playerid][pAdmin] >= 4) return SystemMessage(playerid, "You are not Administrator.");
Is that to let level 1 to 4 use it? Or level 0 to 4 ?
Reply
#6

Its 0 to level 4

You can't do that only level 2 3 and 4 can use that .
Reply
#7

Quote:
Originally Posted by Bomba' Xtreme'Stuntage
Its 0 to level 4

You can't do that only level 2 3 and 4 can use that .
Then How can some admin System do that? Like Lux Admin system level 1 and 2 can use /slap but not level 0
Reply
#8

Oops My mistake

pawn Код:
if(pInfo[playerid][pAdmin] <= 2) return SystemMessage(playerid, "You are not Administrator.");
Now level 2 3 4 can use that command
Sorry
Reply
#9

Quote:
Originally Posted by Bomba' Xtreme'Stuntage
Oops My mistake

pawn Код:
if(pInfo[playerid][pAdmin] <= 2) return SystemMessage(playerid, "You are not Administrator.");
Now level 2 3 4 can use that command
Sorry
When I compile I just get this error: Unreachable Code
Reply
#10

Hmm, i have no idea then, i complied then i got no errors.

But im going to sleep now
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)