OnPlayerText problems, oh joy..
#1

pawn Код:
#define     ChatFilter      "on"
new SwearCounter[MAX_PLAYERS] = 0;
new FilteredWords[2][] =
{
    "fuck",
    "cunt"
};
pawn Код:
if(strcmp(ChatFilter, "on")) {
        for(new filter; filter < sizeof(FilteredWords); filter++){
            if(strfind(text, FilteredWords[filter], true) != -1)
            {
                SendClientMessage(playerid, c_red, "Swearing is forbidden on this server -- Do not swear!");
                SwearCounter[playerid]++;
                printf("[%s] Swear Count: %d", pName(playerid), SwearCounter[playerid]);
                if(SwearCounter[playerid] == 3) {
                    ClearChat(playerid);
                    SendClientMessage(playerid, c_red, "You have been kicked from the server!");
                    SendClientMessage(playerid, c_white, "Reason: Excessive swearing");
                    new string[128];
                    format(string, sizeof(string), "[KICK] %s has been kicked by Sherrif Tom, Reason: Excessive Swearing!", pName(playerid));
                    SendClientMessageToAll(c_red, string);
                    Kick(playerid);
                    printf("[KICK] %s has been kicked by Sherrif Tom | Reason: Excessive Swearing.", pName(playerid));
                }
                return 0;
            }
        }
    }
Yet, I can continue to swear in-game without any precautions. Any idea?
Reply
#2

PHP код:

#include <a_samp>
#define MAX_WORD_LEN 18 // Max lenght of a swear word
#define MAX_WORDS 122   // Max amount of swearwords
#define MAX_SWEARCOUNT 5 // Max warnings before kick
new swearCount[MAX_PLAYERS];
// ENGLISH
new swear[][MAX_WORD_LEN] =
{
    {
"anus"},
    {
"arsehole"},
    {
"ass"},
    {
"bitch"},
    {
"blowjob"},
    {
"boner"},
    {
"bullshit"},
    {
"clit"},
    {
"cock"},
    {
"cum"},
    {
"cunt"},
    {
"dick"},
    {
"dildo"},
    {
"douche"},
    {
"fag"},
    {
"fellatio"},
    {
"fuck"},
    {
"fudgepacker"},
    {
"gay"},
    {
"damn"},
    {
"gooch"},
    {
"handjob"},
    {
"hard-on"},
    {
"homo"},
    {
"homodumbshit"},
    {
"humping"},
    {
"jerkoff"},
    {
"jigaboo"},
    {
"jizz"},
    {
"jungle-bunny"},
    {
"junglebunny"},
    {
"kooch"},
    {
"kootch"},
    {
"kunt"},
    {
"kyke"},
    {
"lesbian"},
    {
"lesbo"},
    {
"lezzie"},
    {
"mcfagget"},
    {
"minge"},
    {
"mothafucka"},
    {
"motherfucker"},
    {
"motherfucking"},
    {
"muff"},
    {
"muffdiver"},
    {
"munging"},
    {
"negro"},
    {
"nigga"},
    {
"niglet"},
    {
"nutsack"},
    {
"paki"},
    {
"panooch"},
    {
"pecker"},
    {
"peckerhead"},
    {
"penis"},
    {
"piss"},
    {
"polesmoker"},
    {
"pollock"},
    {
"poonani"},
    {
"porchmonkey"},
    {
"prick"},
    {
"punanny"},
    {
"punta"},
    {
"pussies"},
    {
"pussy"},
    {
"pussylicking"},
    {
"puto"},
    {
"queef"},
    {
"renob"},
    {
"rimjob"},
    {
"ruski"},
    {
"sandnigger"},
    {
"schlong"},
    {
"scrote"},
    {
"shit"},
    {
"shiz"},
    {
"shiznit"},
    {
"skank"},
    {
"skullfuck"},
    {
"slut"},
    {
"slutbag"},
    {
"smeg"},
    {
"snatch"},
    {
"tard"},
    {
"testicle"},
    {
"thundercunt"},
    {
"tit"},
    {
"twat"},
    {
"twatwaffle"},
    {
"unclefucker"},
    {
"vag"},
    {
"vagina"},
    {
"vjayjay"},
    {
"wank"},
    {
"whore"},
    {
"whorebag"},
    {
"whoreface"},
    {
"wop"},
    {
"@gmail"},
    {
"@live"},
    {
"@msn"},
    {
"@hotmail"},
    {
".de"},
    {
".cc"},
    {
"www."},
    {
".com"},
    {
".co"},
    {
".uk"},
    {
".org"},
    {
".net"},
    {
".info"},
    {
".tk"}
}; 
PHP код:
public OnPlayerDisconnect(playeridreason){
    
swearCount[playerid] = 0;
}
public 
OnPlayerText(playeridtext[])
{
    if((
strlen(text) < 3) || (text[0] == '/') || (text[0] == '#') || (text[0] == '!')) return 1;
    new 
offset;
    new 
len;
     for(new 
i=0i<MAX_WORDSi++)
    {
        
offset strfind(textswear[i], true);
        if(
offset > -1)
        {
            
len strlen(swear[i]);
            if(
len 3) break;
            for(new 
y=0y<leny++)
            {
                
text[offset+y] = '*';
            }
            
swearCount[playerid]++;
            new 
string[64];
            
format(stringsizeof(string), "Swearing is not allowed here, warning %d/%d"swearCount[playerid], MAX_SWEARCOUNT);
            
SendClientMessage(playerid0xE60000FFstring);
               if(
swearCount[playerid] >= MAX_SWEARCOUNT)
            {
                new 
name[24];
                
GetPlayerName(playeridnamesizeof(name));
                
format(stringsizeof(string), "*** %s has been kicked for offensive language"name);
                
SendClientMessageToAll(0xE60000FFstring);
                
Kick(playerid);
                break;
            }
            break;
        }
    }
    return 
1;

I took this from my released script, hope it helps.

EDIT: I think you're problem is that you're doing ( != -1) when it should be ( > 1) in strfind()
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)