SA-MP Forums Archive
IsInteger (Closed) - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: IsInteger (Closed) (/showthread.php?tid=112536)



IsInteger (Closed) - Raicoon - 08.12.2009

Hi,
I'm looking for a function, which checks, if a text that is input from dialog, is a integer.
I've already use the search function but I didn't find anything useful.

I hope you can help me

- Raicoon


Re: IsInteger - dice7 - 08.12.2009

Out of my head

pawn Код:
stock IsInteger(text[])
{
  if(strval(text) == 0)
  {
    return false
  }
  return true;
}



Re: IsInteger - Kurence - 08.12.2009

And what if he will enter "0" into that dialog?


Re: IsInteger - woot - 08.12.2009

pawn Код:
stock IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0')
        {
            return 0;
        }
    }
    return 1;
}



Re: IsInteger - Joe Staff - 08.12.2009

pawn Код:
stock IsNumeric(string[])
{
  for(new o; o<strlen(string);o++)
  {
    if((string[o]>'9')||(string[0]<'0'))return 0;
  }
  return 1;
}
bah, he beat me.


Re: IsInteger - Raicoon - 08.12.2009

Ok it works. Thanks //exora and Joe Staff your codes helped me a lot!

- Raicoon