05.09.2015, 01:52
Quote:
Not sure if this is a bug with coding, or what.
Sometimes, my admins are noticing that sscanf is returning "no player found" while using the 'u' specifier. Код:
if(sscanf(params, "us[30]",id,rsn)) return SendClientMessage(playerid,COLOR_RED,"Usage: /ban <playerid> <reason>"); I did notice that this wont happen if the 'd' specifier is used, but 'u' is better because you can type the name also. |
Second, you could easily just make a new specifier, example below.
pawn Код:
SSCANF:players(string[])
{
new ret = INVALID_PLAYER_ID;
if(isnumeric(string))
{
new p = strval(string); // Better than using strval twice.
if(IsPlayerConnected(p))
ret = p;
}
else foreach(new p: Player)
{
if(strfind(ReturnPlayerName(p), string, true) != -1)
{
ret = p;
break;
}
}
return ret;
}
pawn Код:
new targetid;
sscanf(params, "k<players>", targetid))
if(targetid == INVALID_PLAYER_ID)
return SendClientMessage(playerid, -1, "Error [Command]: Invalid player name/id specified.");
else
{
// Execute rest of command.
}