29.12.2012, 12:06
As phantomcraft said, use ZCMD. It's faster and way efficient. Use sscanf too.
On topic; You can have my /setlevel command (I changed it to /setadmin so it can be easier for you)
Note; It's tested and works 100%. I deleted some of them (like to check if the selected ID is logged in or not) but you can always add some more things in the code.
On topic; You can have my /setlevel command (I changed it to /setadmin so it can be easier for you)
pawn Код:
CMD:setadmin(playerid, o[])
{
if(IsPlayerAdmin(playerid) || pInfo[playerid][pAdmin] == 1337) {
new string[128], ID, cmdreason;
if(sscanf(o,"ui",ID,cmdreason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /setadmin (Player Name/ID) (Level [0 - 7 | 1336 - 1337])");
else if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, "The player name/ID you entered is not connected to the server.");
else if(cmdreason == pInfo[ID][pAdmin])
{
format(string,sizeof(string),"Player/Administrator %s(%d) is already at level %d.",PlayerName(ID),ID,cmdreason);
SendClientMessage(playerid,COLOR_RED,string);
}
// this one down here is the current invalid levels. the levels are between 8 and 1335.
else if(cmdreason > 7 && cmdreason < 1336) SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid level.");
else {
pInfo[ID][pAdmin] =cmdreason;
format(string,sizeof(string),"Administrator %s has set your admin level to %d.",PlayerName(playerid),cmdreason);
SendClientMessage(ID, COLOR_ADMIN, string);
format(string,sizeof(string),"You have set %s(%d)'s level to %d.",PlayerName(ID),ID,cmdreason);
SendClientMessage(playerid, COLOR_ADMIN, string);
format(string,sizeof(string),"An administrator has set %s's level to %d.",PlayerName(ID),cmdreason);
SendClientMessageToAll(COLOR_LIMEGREEN, string);
format(string,sizeof(string),"%s(%d) has set %s(%d)'s level to %d.",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdreason);
print(string);
}
} else SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command!");
return 1;
}