if(strcmp(cmdtext, "/makehelper", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 5 || PlayerInfo[playerid][pHelpers] >= 3)
{
new targetid, level;
if(sscanf(cmdtext,"ui", targetid, level)) return SendClientMessage(playerid, COLOR_GREY, "[USAGE] /makehelper [id] [level]");
format(string, sizeof(string), "You have made (%d) %s a Helper, current level: %d", targetid, PlayerName(targetid), level);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "You were made a Helper by admin/head Helper (%d)%s", playerid, PlayerName(playerid));
SendClientMessage(targetid, COLOR_WHITE, string);
PlayerInfo[targetid][pHelpers] = level;
}
printf("/makehlper command returned");
return 1;
}
CMD:makehelper(playerid, params[])
{
new id, level;
if(sscanf(params, "ui", id, level)) return SendClientMessage(playerid,-1, "USAGE: /makehelper [id] [level]");
format(string, sizeof(string), "You have made (%d) %s a Helper, current level: %d", id, PlayerName(id), level);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "You were made a Helper by admin/head Helper (%d)%s", playerid, PlayerName(playerid));
SendClientMessage(targetid, COLOR_WHITE, string);
PlayerInfo[id][pHelpers] = level;
return 1;
}
try this
pawn Код:
|
if(sscanf(cmdtext, "ui", id, level)) return SendClientMessage(playerid,-1, "USAGE: /makehelper [id] [level]");//your code //change cmdtext to params and it should work(as Windows32 did in his post to) if(sscanf(params, "ui", id, level)) return SendClientMessage(playerid,-1, "USAGE: /makehelper [id] [level]");//your code
Yeah, sscanf is the problem, use:
Код:
if(sscanf(cmdtext, "ui", id, level)) return SendClientMessage(playerid,-1, "USAGE: /makehelper [id] [level]");//your code //change cmdtext to params and it should work(as Windows32 did in his post to) if(sscanf(params, "ui", id, level)) return SendClientMessage(playerid,-1, "USAGE: /makehelper [id] [level]");//your code |
if(strcmp(cmdtext, "/makehelper", true) == 0)
CMD:makehelper(playerid, params[])
Just a note. ZCMD is the exact same principle as for when you're using strcmp. The only difference is the parameters of the command.
STRCMP: pawn Код:
pawn Код:
|
I actually found a solution for mixing ZCMD & STRCMP in the script, I've fixed the sscanf issue but whenever I do that command, it returns, Unknown Command at the bottom, so it isnt reaching return 1; <- its a zcmd version now
|
You can't run strcmd and Zcmd at the same time! either you use strcmd or zcmd! else it will throw SERVER:UNKNOWN COMMAND!
|
Yes you can. "OnPlayerCommandText" is never called, but there are two new callbacks - "OnPlayerCommandReceived" and "OnPlayerCommandPerformed" added. If you put your strcmp commands in the former they should work - not that it's at all recommended.
|