30.08.2009, 20:00
Why is this code not good?
I want that if a player is not rconlogged or if a player has not admin level 3 is that the command can not use
Can anybody see the bug?
(srry for bad bad english)
Quote:
if(strcmp(cmd, "/ban", true) == 0) { if ((!IsPlayerAdmin(playerid)) || adminlevel[playerid] < 3) { SendClientMessage(playerid, COLOR_RED, "You have not enough rights to use this command!"); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD, "USAGE: /ban [playerid] [reason]"); return 1; } if(!IsPlayerConnected(playerid)) { SendClientMessage(playerid, COLOR_RED, "That player is not connected!"); return 1; } giveplayerid = strval(tmp); new length = strlen(cmdtext); while ((idx < length) && (cmdtext[idx] <= ' ')) { idx++; } new offset = idx; new result[64]; while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) { result[idx - offset] = cmdtext[idx]; idx++; } result[idx - offset] = EOS; if ((IsPlayerAdmin(giveplayerid))) { SendClientMessage(playerid, COLOR_RED, "You can not ban the server owner!"); return 1; } if ((IsPlayerAdmin(playerid)) || adminlevel[playerid] >= 3) { GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); GetPlayerName(playerid, sendername, sizeof(sendername)); format(string,sizeof(string),"*** Admin %s has banned %s (reason: %s) ***",sendername,giveplayer, result); SendClientMessageToAll(COLOR_RED,string); printf("*** Admin %s has banned %s with reason: %s ***",sendername,giveplayer, result); Ban(giveplayerid); return 1; } else { SendClientMessage(playerid,COLOR_RED,"You have not enough rights to use this command!"); return 1; } } |
Can anybody see the bug?
(srry for bad bad english)