13.01.2016, 03:22
(
Последний раз редактировалось Black Axe; 13.01.2016 в 04:37.
)
Hi!
I've always been using strcmp & strtok until recently I realized how dumb I was as sscanf & ZCMD are SO MUCH easier. The problem I have with sscanf tho, is how to check if the first params were entered while the other were not?
Here is the command I am converting:
Now I am not sure how to check if the first params [u - playerid] has been entered but the 2nd were not so it would list the admin levels, any ideas? thanks!
EDIT: I used a different solution to fix the issue but I would really love to know if there's a method that would do what I need done.
I've always been using strcmp & strtok until recently I realized how dumb I was as sscanf & ZCMD are SO MUCH easier. The problem I have with sscanf tho, is how to check if the first params were entered while the other were not?
Here is the command I am converting:
Код:
COMMAND:makeadmin(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] >= 5) { if(sscanf(params, "ui", newadmin, adminlevel)) return SendClientMessage(playerid, -1, "USAGE: /makeadmin [player-id] [admin-level]") new newadmin; new adminlevel; new prom[128]; if(strlen(tmp) >= 0 && !strlen(tmp2)) { 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; } if(IsPlayerConnected(newadmin)) { new newadminname[MAX_PLAYER_NAME]; 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 { SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: That player is offline!"); } } }
EDIT: I used a different solution to fix the issue but I would really love to know if there's a method that would do what I need done.