26.12.2018, 03:44
That's because the sscanf statement is using an optional parameter, and sscanf will never return true if you're only using an optional parameter in this instance.
There are multiple ways to do this but they're all essentially the same.
Examples:
There are multiple ways to do this but they're all essentially the same.
Examples:
PHP код:
CMD:kill(playerid, params[])
{
new lookupid = INVALID_PLAYER_ID;
if(sscanf(params, "u", lookupid)) {
SendClientMessage(playerid, -1, "USAGE: You can use \"/kill [playerid]\"");
SetPlayerHealth(playerid, 0.0);
return 1;
}
if(!IsPlayerConnected(lookupid)) {
SendClientMessage(playerid, -1, "ERROR: The specified player is not connected.");
return 1;
}
SetPlayerHealth(lookupid, 0.0);
return 1;
}
PHP код:
CMD:kill(playerid, params[])
{
new lookupid = -1;
sscanf(params, "U(-1)", lookupid);
if(lookupid == -1)
{
SendClientMessage(playerid, -1, "USAGE: You can use \"/kill [playerid]\"");
SetPlayerHealth(playerid, 0.0);
}
else if(!IsPlayerConnected(lookupid))
SendClientMessage(playerid, -1, "ERROR: The specified player is not connected.");
else
SetPlayerHealth(lookupid, 0.0);
return 1;
}