How to make a check for not-allowed symbols? - 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: How to make a check for not-allowed symbols? (
/showthread.php?tid=71020)
How to make a check for not-allowed symbols? -
HB - 29.03.2009
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,
Re: How to make a check for not-allowed symbols? -
bogeymanEST - 29.03.2009
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.
Re: How to make a check for not-allowed symbols? -
HB - 29.03.2009
So I have to add all the invalid symbols. Right, isn't there a loop for such a thing?
Re: How to make a check for not-allowed symbols? -
bogeymanEST - 29.03.2009
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
Re: How to make a check for not-allowed symbols? -
HB - 29.03.2009
Ah thats where I was searching for, thanks!
Re: How to make a check for not-allowed symbols? -
PawnNewCommer - 22.07.2009
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
![Cool](images/smilies/cool.gif)
: warning 202: number of arguments does not match definition