Anti Swear
#1

hello. I've used RyDeR's function to make antiswear for cmds. It works for text but not for commands :S It should work for commands like this: Player A writes: /adminchat FUCK, and the text will be ****. Doesnt work, it doesnt gets replaced.

pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if (!iSpawned[playerid])
    {
        return ShowInfoBox(playerid, "~w~Jus dar ~r~negalite ~w~rasyti, pirmiausia prisijunkite!"), 0;
    }
    if (iCommandSpam[playerid] + 1000 > GetTickCount() && iCommandSpam[playerid] > 0)
    {
        return ShowInfoBox(playerid, "~w~Pries naudojant komanda vel, palaukite ~g~sekunde!"), 0;
    }
    iCommandSpam[playerid] = GetTickCount();
    ChangeSwear(cmdtext);
    return true;
}
pawn Код:
stock ChangeSwear(Text[], Symbol = '*')
{
    new iWords = sizeof(BadWords), i;
    for (new BadWord; BadWord != iWords; ++BadWord)
    {
        while ((i = strfind(Text, BadWords[BadWord], true)) != -1)
        {
            for (new x = (i + strlen(BadWords[BadWord])); i != x; ++i)
            {
                Text[i] = Symbol;
            }
        }
    }
    return true;
}
Reply
#2

cmdtext in zcmd is only passed for reference - you can't change the value of it there.

If you look in zcmd's include code, you can probably paste the code in OnPlayerCommandText to replace the swear words in there.
Reply
#3

Thank you, I'll try that
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)