#1

I wanted to block the use of more than 4 numbers in a command of the announcement of my server.

I tried to do so
but gave an error

Код:
if(strlen(IsNumeric(result)) >4 )
            {
	        SendClientMessage(playerid,COLOR_RED,"The use of numbers");
    	    return 1;
            }
Anybody know how I can do??
Reply
#2

Um?

Код:
if(strval(result) > 4 )
Reply
#3

That way you step blocks ads like this:

12345asdasda
12 345

so that ads like this:

asdsad12345
a12345

he does not block
Reply
#4

I assume the result[] is the Advertisement the player added
and it only checks the first character, you need to describe which way you want to implement it.

1. block it if the first char have a numeric character

pawn Код:
if( result[0] >= '0' && result[0] <= '9' )
{
    SendClientMessage( playerid, 0xFF0000AA, "* Don't put numbers in front of the advertisement!!");
    return 1;
}
2. block it if any of first 5 char have a numeric character

pawn Код:
for( new i = 0 ; i < 5 ; i++ )
{
    if( result[i] >= '0' && result[i] <= '9' )
    {
        SendClientMessage( playerid, 0xFF0000AA, "* Don't put numbers in front of the advertisement!!");
    return 1;
    }
}
3. same as (2), but ignores spacing

pawn Код:
new i = 0, i_without_spacing = 0;
while( i_without_spacing < 5 && i < strlen( result ) )
{
    switch( result[i] )
    {
        case ' ': //ignores spacing
        {
            i++;
            continue;
        }
        case '0'..'9':
        {
            SendClientMessage( playerid, 0xFF0000AA, "* Don't put numbers in front of the advertisement!!");
            return 1;
        }
        default:
        {
            i++;
            i_without_spacing++;
        }
    }
}
4. blocks if a player types more than 5 numeric characters ( no matter how long he typed )

pawn Код:
new numerics = 0;
for( new i = 0, j = strlen( result ) ; i < j ; i ++ )
{
    if( result[i] >= '0' && result[i] <= '9' )
    {
        numerics++;
        if( numerics >= 5 )
        {
            SendClientMessage( playerid, 0xFF0000AA, "* Don't put numbers in front of the advertisement!!");
            return 1;
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)