how to block certain characters? - 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)
+--- Thread: how to block certain characters? (
/showthread.php?tid=593026)
how to block certain characters? -
DemME - 01.11.2015
Hey so probably I thought to myself, if it's possible to block few written characters, such as "dot (.), ( | ) and {}" for an example, I tried so many way, I don't find any better way to solve it. thanks for help if you do so.
Re: how to block certain characters? -
Kevln - 01.11.2015
https://sampwiki.blast.hk/wiki/Strfind
Re: how to block certain characters? -
Vince - 01.11.2015
PHP код:
static const cChars[] = {'.', '|', '{', '}'}; // note: single quotes
new bool:invalid = false;
for(new i, j = strlen(input); i < j && !invalid; i++)
{
for(new c; c < sizeof(cChars); c++)
{
if(input[i] == cChars[c])
{
invalid = true;
break;
}
}
}
if(invalid)
{
// found invalid characters in input
}
else
{
// no invalid chars
}
You should probably use this as a function if you intend to use it in different places.