28.11.2013, 10:34
Without checking if the player is connected and that id is an invalid player, it's going to show the unknown command message due to the runtime error: Array index out of bounds.
I believe the problem is because of the sscanf. Try updating the plugin and include file to the latest version and re-compile the scripts. Run the server and try again.
PS: Don't use return while checking the level because the rest of the code won't be executed.
I believe the problem is because of the sscanf. Try updating the plugin and include file to the latest version and re-compile the scripts. Run the server and try again.
PS: Don't use return while checking the level because the rest of the code won't be executed.
pawn Код:
CMD:setlevel(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return 0;
new pID,level,rank[128];
if(sscanf(params,"rd",pID,level)) return SendClientMessage(playerid,COLOR_WHITE,"USAGE: /setlevel [playerid] [level]");
if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_GREY,"Player is not connected.");
if(pInfo[pID][AdminLevel] > pInfo[playerid][AdminLevel]) return SendClientMessage(playerid,COLOR_WHITE,"You can't use this command on your colleauge");
if(pInfo[pID][AdminLevel] > level)
{
if(level == 1) format(rank,sizeof(rank),"{FF8800}Server Moderator {FFFFFF}");
else if(level == 2) format(rank,sizeof(rank),"{0000FF}Global Moderator {FFFFFF}");
else if(level == 3) format(rank,sizeof(rank),"{FF0000}Admin {40FF00}");
else if(level == 4) format(rank,sizeof(rank),"{40FF00}Super Admin {FFFFFF}");
else if(level == 5) format(rank,sizeof(rank),"{40FF00}Head Admin {FFFFFF}");
format(string,sizeof(string),"%s has been demoted to %s by "SERVER_NAME" management.",pID,rank);
}
else if(pInfo[playerid][AdminLevel] < level)
{
if(level == 1) format(rank,sizeof(rank),"{FF8800}Server Moderator {FFFFFF}");
else if(level == 2) format(rank,sizeof(rank),"{0000FF}Global Moderator {FFFFFF}");
else if(level == 3) format(rank,sizeof(rank),"{FF0000}Admin {40FF00}");
else if(level == 4) format(rank,sizeof(rank),"{40FF00}Super Admin {FFFFFF}");
else if(level == 5) format(rank,sizeof(rank),"{40FF00}Head Admin {FFFFFF}");
format(string,sizeof(string),"%s has been promoted to %s by "SERVER_NAME" management.",pID,rank);
}
SendClientMessageToAll(COLOR_WHITE,string);
pInfo[pID][AdminLevel] = level;
return 1;
}