strmfind numbers. - 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: strmfind numbers. (
/showthread.php?tid=607498)
strmfind numbers. -
Luicy. - 20.05.2016
How can I check if a string contains numbers?
Without repeating
if(strfind(playername(playerid), "0", true) != -1)
Ten times.
Re: strmfind numbers. -
Konstantinos - 20.05.2016
You check each character with a loop:
pawn Code:
ContainsNumbers(const _str_[])
{
for (new i, j = strlen(_str_); i != j; i++)
{
if ('0' <= _str_[i] <= '9') return 1;
}
return 0;
}
Re: strmfind numbers. -
Luicy. - 20.05.2016
Is there any other smaller way to check other than stocks?
Re: strmfind numbers. -
VVWVV - 20.05.2016
Use this function (with loop, i.e. with repeating, because without repeating isn't work):
Code:
stock
NumbersInString(const string[], string_length = sizeof string)
{
static pos;
for(pos = -1; ++pos != string_length;)
{
switch (string[i])
{
case '\0':
break;
case '0' .. '9':
return 1;
}
}
}