Max 8 numbers in one chat.
#7

Quote:
Originally Posted by Necip
Посмотреть сообщение
Bump. I made something, but the problem is, when it detects 8 characters, any of them, it says advertising. Here is the script. Can someone make it with numbers only?
pawn Код:
stock IsAnIP(const str[])
{
    new i;
    new numbers;
    new len = strlen(str);
    while (i < len)
    {
        if (str[i] >= '0' || str[i] <= '9') numbers++;
        i++;
    }
    if (numbers > 7) return 1;
    return 0;
}
there's just one small mistake you've made
instead of using OR, you have to use AND
cuz that control structure should only result in true when the char is within the range you defined by '0' and '9'
c++ example checking for uppercase chars and replacing them with lower case ones:
Код:
void strKlein(char *c)
{
	for (short i = 0; c[i] != '\0'; i++)
		c[i] = (c[i] > 64 && c[i] < 91) ? (c[i]+32) : (c[i]);
}
replace this line
Код:
if (str[i] >= '0' || str[i] <= '9') numbers++;
with this
Код:
if (str[i] >= '0' && str[i] <= '9') numbers++;
and it'll be fine
Reply


Messages In This Thread
Max 8 numbers in one chat. - by Necip - 14.03.2014, 13:31
Re : Max 8 numbers in one chat. - by Golimad - 14.03.2014, 13:57
Re: Max 8 numbers in one chat. - by Necip - 14.03.2014, 14:12
Re : Max 8 numbers in one chat. - by Golimad - 14.03.2014, 14:18
Re: Max 8 numbers in one chat. - by Necip - 15.03.2014, 13:10
Re : Max 8 numbers in one chat. - by Golimad - 15.03.2014, 13:13
AW: Max 8 numbers in one chat. - by CutX - 15.03.2014, 13:17
Re: Max 8 numbers in one chat. - by Emmet_ - 15.03.2014, 13:20
Re: Max 8 numbers in one chat. - by Djole1337 - 15.03.2014, 13:20
Re: Max 8 numbers in one chat. - by RajatPawar - 15.03.2014, 13:27

Forum Jump:


Users browsing this thread: 1 Guest(s)