strfind but then the amount of find. - 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: strfind but then the amount of find. (
/showthread.php?tid=322036)
strfind but then the amount of find. -
milanosie - 29.02.2012
Hi there, is there a way to find out how many times something is found?
like
pawn Код:
new ipfind = strfind(params, ".", true);
new portfind = strfind(params, ":", true);
if(ipfind != -1 && portfind != -1)
{
if(PlayerInfo[playerid][AdminLevel] < 3)
{
new string43[128];
format(string43, sizeof(string43), "%s just got kicked for Advertising by **AntiCheat V2.0**", SenderName);
ProxDetector(10000000000.0, playerid, string43, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF);
SendClientMessage(playerid, COLOR_RED, "Advertising is not allowed!");
Kick(playerid);
}
And it only kicks if "." is found like 3 times?
Re: strfind but then the amount of find. -
Stylock - 29.02.2012
Regular expression is way better than strfind method. See
this post.
Re: strfind but then the amount of find. -
milanosie - 29.02.2012
Like what? I dont understand
Re: strfind but then the amount of find. -
milanosie - 01.03.2012
So I tried to understand this code:
pawn Код:
stock ContainsIPEx(const string[])
{
static
RegEx:rCIP
;
if ( !rCIP )
{
rCIP = regex_build("(.*?)([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})(.*?)");
}
return regex_match_exid(string, rCIP);
}
by Fro1sha
But how do I actually use it?
Re: strfind but then the amount of find. -
Stylock - 01.03.2012
Place that function somewhere in your script and use it like this:
pawn Код:
if(ContainsIPEx(params))
{
//ban
}
Re: strfind but then the amount of find. -
milanosie - 01.03.2012
thanks