Help - 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: Help (
/showthread.php?tid=170109)
Help -
Guerek - 21.08.2010
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??
Re: Help -
Dodus - 21.08.2010
Um?
Код:
if(strval(result) > 4 )
Re: Help -
Guerek - 21.08.2010
That way you step blocks ads like this:
12345asdasda
12 345
so that ads like this:
asdsad12345
a12345
he does not block
Re: Help -
dax123 - 22.08.2010
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;
}
}
}