Only typing numbers
#3

You can use the function 'IsNumeric'. It's not a default part of the SA-MP library but it's easily implemented using a macro or added function.

pawn Код:
stock IsNumeric(const string[]) //@Credits to CaHbKo.
{
        for (new i = 0, j = strlen(string); i < j; i++)
        {
                if (string[i] > '9' || string[i] < '0') return 0;
        }
        return 1;
}
Using that, you can check if they only typed in numbers, if there are any non numeric characters in the string, it will return 0, and when it does, you can send them an error and prompt them to enter their age again.
Reply


Messages In This Thread
Only typing numbers - by Elysian` - 26.11.2012, 20:15
Re: Only typing numbers - by Nordic - 26.11.2012, 21:19
Re: Only typing numbers - by Bicentric - 26.11.2012, 21:36

Forum Jump:


Users browsing this thread: 1 Guest(s)