SA-MP Forums Archive
better advertisement check - 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: better advertisement check (/showthread.php?tid=244055)



better advertisement check - Donya - 25.03.2011

pawn Код:
stock AdvertisementCheck(string[])
{
    if(!isnull(string))
    {
        if(strfind(string,"www.",true)!=-1 || strfind(string,"http://",true)!=-1 || !strfind(string,".com",false) || !strfind(string,".net",false)
        || !strfind(string,".de",false) || !strfind(string,".org",false) || !strfind(string,".blog",false) || !strfind(string,".info",false)
        || !strfind(string,".co.cc",false))
        {
            return true;
        }
        new c=1,idx,tmp[32],ip[4],len=strlen(string);
        for(new i=0;i<len;i++)
            if(string[i]==' ')
                c++;
        for(new i=0;i<c;i++)
        {
            idx=0;
            tmp=strtok(string,idx);
            idx=0;
            tmp=strtok2(tmp,idx,':');
            ip=SplitIp(tmp);
            if(ip[0]>=0 && ip[1]>=0 && ip[2]>=0 && ip[3]>=0) // We have found an IP :o
                return true;
        }
    }
    return false;
}
say i accidentally type .complain i get banned... any ideas


Re: better advertisement check - Donya - 28.03.2011

bump


Re: better advertisement check - Tee - 28.03.2011

You should not get banned because you did not search for it in strfind. But test it on a local server.


Re: better advertisement check - Donya - 28.03.2011

|| !strfind(string,".com",false) is there

but its stupid if u write .computer or something..


Re: better advertisement check - Antonio [G-RP] - 28.03.2011

I suggest using sscanf, because ".com" will allow for everything after the .com aswell, eg. .complain, .computer, .comply


Re: better advertisement check - Tee - 28.03.2011

Antonio, can you show me how to use sscanf to check strings?


Re: better advertisement check - Donya - 28.03.2011

i saw sscanf version of checking strings, but it would only check if the string contained the ip only

edit: E.G

pawn Код:
sscanf(text,"dcdcdcdc",text[0],.,text[1],.,text[2],.,text[3],:);
but if u like loop through the string, there might be problems


pawn Код:
for(new i; i<text[i]; i++
{
    sscanf(text[i],"dcdcdcdc",text[i],.,text[i],.,text[i],.,text[2],:);
}