stock AntiAdvertising, not working.
#1

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;
}
Reply
#2

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.
Reply
#3

True, i didnt make this by myself...

I failed, could you do it for me?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)