SA-MP Forums Archive
trying to add 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: trying to add isnumeric (/showthread.php?tid=636409)



trying to add isnumeric - HoussemGaming - 26.06.2017

Hey all.
i tried to add if(!isnumeric(params)) into my fs but it says Undefined Symbol : isnumeric.
Can ya help me ?


Re: trying to add isnumeric - GSFBart - 26.06.2017

PHP код:
stock isNumeric(const string[]) {
    new 
length=strlen(string);
    if (
length==0) return false;
    for (new 
0lengthi++) {
        if (
        (
string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+'// Not a number,'+' or '-'
        
|| (string[i]=='-' && i!=0)                                             // A '-' but not at first.
        
|| (string[i]=='+' && i!=0)                                             // A '+' but not at first.
        
) return false;
    }
    if (
length==&& (string[0]=='-' || string[0]=='+')) return false;
    return 
true;




Re: trying to add isnumeric - Vince - 26.06.2017

PHP код:
IsNumeric(text[])
    return !
sscanf(text"{d}"); 
Tada!