SA-MP Forums Archive
stock AntiAdvertising, not working. - 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: stock AntiAdvertising, not working. (/showthread.php?tid=226062)



stock AntiAdvertising, not working. - Unknown123 - 14.02.2011

pawn Код:
stock AntiAdvertising(playerid, text[], chances)
{
    new Chance[MAX_PLAYERS] = 0;
    new var, pos, oldpos;
    oldpos = strfind(text, ".", true);
    if(strval(text[oldpos - 1]) == 0) return 1;

    while((pos = strfind(text, ".", true, pos + 1)) != -1 && pos - oldpos <= 4)
    {
        var++;

        if(strval(text[pos + 1]) == 0 || text[pos + 1] == ' ') return 1;
        oldpos = pos;

        if(var == 3 && (pos = strfind(text, ":", true, pos + 1)) != -1)
        {
            if(strval(text[pos + 1]) == 0 || text[pos + 1] == ' ') return 1;

            Chance[playerid]++;
            if(Chance[playerid] > chances)
            {
                BanEx(playerid, "Advertising");
                return 0;
            }
        }
    }
    return 1;
}
It should use like:
pawn Код:
public OnPlayerText(playerid, text[])
{
    AntiAdvertising(playerid, text, 5); //Gives he 5 chances, If he Type a Server IP more that 5 times ge get banned.
    return 1;
}



Re: stock AntiAdvertising, not working. - Antonio [G-RP] - 14.02.2011

I can tell that you didn't write that code yourself, obviously because you don't know how to use this.

Anyway, try putting 'Chance[playerid]' as a global var, instead, so every time OnPlayerText is called, it will update Chances (if they are advertising) and ban them when they go over MAX_CHANCES(also define that at top of script).

This way, you don't need to use

pawn Код:
public OnPlayerText(playerid, text[])
{
    AntiAdvertising(playerid, text, 5); //Gives he 5 chances, If he Type a Server IP more that 5 times ge get banned.
    return 1;
}
And it will actually work.


Re: stock AntiAdvertising, not working. - Unknown123 - 15.02.2011

True, i didnt make this by myself...

I failed, could you do it for me?