Help With IsNumeric - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help With IsNumeric (
/showthread.php?tid=514361)
Help With IsNumeric -
AroseKhanNiazi - 21.05.2014
pawn Код:
new nPlayer;
if(!sscanf(params,"u",nPlayer))
pawn Код:
if(isNumeric(params)) format(string, sizeof(string), "%d Is Not A Valid ID.", nPlayer);
if(!isNumeric(params)) format(string,sizeof(string),"%s Is Not An Valid Name.",nPlayer);
if we type any name and that player is offline it will say an symbol "y" is not an valid name so is there any other way to do it
Re: Help With IsNumeric -
BroZeus - 21.05.2014
waht do u want to do exactly check if player in online or check if user has entered a valid id?
Re: Help With IsNumeric -
AroseKhanNiazi - 21.05.2014
i want to check that if an player types an invalid id it will say that %d is not an valid id %d[any id]
and if it types any text and that is not an valid player name %s is not an valid name %s[any text he typed]
Re: Help With IsNumeric -
AndySedeyn - 21.05.2014
Add this under your if(sscanf(...))
pawn Код:
else if(nPlayer == INVALID_PLAYER_ID) return SendClientMessage(/*your code*/);
if you really want to show which ID the player has entered use this:
pawn Код:
else if(nPlayer == INVALID_PLAYER_ID)
{
format(string, sizeof(string), "%d is not a valid ID", nPlayer);
SendClientMessage(playerid, /*COLOR here*/, string);
}
EDIT:
To optimize your code use sscanf like this:
pawn Код:
if(sscanf(params, "u", nPlayer)) return SendClientMessage(playerid, /*COLOR HERE*/, "[USAGE] /COMMAND [playerid/PartOfName]");
You don't have to, it's a tip