Saving mobile number as string - 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: Saving mobile number as string (
/showthread.php?tid=600203)
Saving mobile number as string -
bugi - 05.02.2016
So i made a system where im saving players mobile numbers to strings like pMobile[50] and now when im using /call command how do i check if he entered text into second parameter or number ? /call jasfojsaofp should return SCM(playerid, -1, "Enter number, not text u fool"); and /call 00908978 return SCM(playerid, -1, "You entered wrong number");
Re: Saving mobile number as string -
Sascha - 05.02.2016
if you are using sscanf, you can just use it like this:
Код:
COMMAND:call(playerid, params[])
{
new number;
if(sscanf(params, "i", number)) return SendClientMessage(playerid, -1, "Enter number, not text u fool");
//some other stuff
return 1;
}
if you don't use sscanf, then you should start using sscanf.
If you don't want to (then you are a fool

) you can use this:
Код:
COMMAND:call(playerid, params[])
{
if(!isNumeric(params)) return SendClientMessage(playerid, -1, "Enter number, not text u fool");
//some other stuff
return 1;
}
if you don't have a isNumeric function already, you can use e.g. this
Код:
stock bool:isNumeric(const string[])
{
if(string[0] != EOS) {
for(new i = -1; ; ) {
switch(string[++i]) {
case '+', '-', '.', '0'..'9': continue;
case EOS: return true;
default: return false;
}
}
}
return false;
}
Re: Saving mobile number as string -
[XST]O_x - 05.02.2016
pawn Код:
IsNumeric(const string[])
{
for(new i = 0, l = strlen(string); i <= l; i++)
{
if(!('0' <= string[i] <= '9')) return 0;
}
return 1;
}
Use this to check the parameter.
Re: Saving mobile number as string -
bugi - 05.02.2016
Ty guys