26.11.2012, 21:36
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.
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.
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;
}