How to make a check for not-allowed symbols?
#1

Hey,

I just wondered, how you could filter out the symbols in sa-mp to prevent that some people do "/changenick &$^&@".
With filtering out I mean making an error to make sure you get an error when you type "/changenick &%$%" for example.
Searching didn't gave me any solutions.

Thanks,
Reply
#2

Use
pawn Код:
if(strfind(insert_new_name_string_here, "&") != -1 ||
strfind(insert_new_name_string_here, "$") != -1 ||
strfind(insert_new_name_string_here, "^") != -1 ||
strfind(insert_new_name_string_here, "@") != -1) return SendClientMesssage(playerid, 0xFF0000FF, "Invalid characters!");
//Here goes your code to change the nick.
Reply
#3

So I have to add all the invalid symbols. Right, isn't there a loop for such a thing?
Reply
#4

You could do a loop...
pawn Код:
for(new i = 0; i < new_name_string_length; i++)
{
    switch(new_name_string[i])
    {
        case '&', '$', '@', '^': return SendClientMessage(playerid, 0xFF0000FF, "Invalid characters!");
        default: continue;
    }
}
//Here goes your code to change the nick
Reply
#5

Ah thats where I was searching for, thanks!
Reply
#6

Quote:
Originally Posted by bogeyman_EST
Use
pawn Код:
if(strfind(insert_new_name_string_here, "&") != -1 ||
strfind(insert_new_name_string_here, "$") != -1 ||
strfind(insert_new_name_string_here, "^") != -1 ||
strfind(insert_new_name_string_here, "@") != -1) return SendClientMesssage(playerid, 0xFF0000FF, "Invalid characters!");
//Here goes your code to change the nick.
this code work...



and this


Quote:
Originally Posted by bogeyman_EST
You could do a loop...
pawn Код:
for(new i = 0; i < new_name_string_length; i++)
{
    switch(new_name_string[i])
    {
        case '&', '$', '@', '^': return SendClientMessage(playerid, 0xFF0000FF, "Invalid characters!");
        default: continue;
    }
}
//Here goes your code to change the nick
what new_name_string_length and new_name_string ?

i do

Код:
		
for(new i = 0; i < strfind(tmp); i++)
{
switch(tmp[i])
{
case '&', '$', '@', '^': return SendClientMessage(playerid, 0xFF0000FF, "Invalid characters!");
default: continue;
}
}
it is not right?
i have error
D:\samp\mod.pwn(1089 : warning 202: number of arguments does not match definition


Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)