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;
}
}
}