13.01.2016, 04:45
use capital "I" specifier for second parameter, this makes the parameter optional to enter, then first you check if player is online, then check if level is entered. Here i make it optional so it can be handled by your code instead of resulting "USAGE: /makeadmin [player-id] [admin-level]".
Not tested yet, hope that helps.
Код:
COMMAND:makeadmin(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] >= 5) { new newadmin, adminlevel; if(sscanf(params, "uI", newadmin, adminlevel)) return SendClientMessage(playerid, -1, "USAGE: /makeadmin [player-id] [admin-level]") if(newadmin == INVALID_PLAYER_ID) { return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: That player is offline!"); } else // player is connected { if(1 <= adminlevel <= 5) // check if entere admin level is 1 to 5 { new newadminname[MAX_PLAYER_NAME], prom[128]; GetPlayerName(newadmin, newadminname, MAX_PLAYER_NAME); format(prom, sizeof(prom), "You have promoted %s to a level %d administrator/moderator", newadminname, adminlevel); SendClientMessage(playerid, 0xFFFFFFFF, prom); format(prom, sizeof(prom), "You have been promoted by Admin %s to a level %d administrator/moderator", RemoveUnderScore(playerid), adminlevel); SendClientMessage(newadmin, 0xFFFFFFFF, prom); PlayerInfo[newadmin][pAdmin] = adminlevel; return 1; } else // level was not entered or not 1 to 5 { SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: Available Adminstration levels are:"); SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: Level 1: Moderator"); SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: Level 2: Junior Admin"); SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: Level 3: General Admin"); SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: Level 4: Community Manager"); SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: Level 5: Executive Admin"); return 1; } } } }