Anti Spam help
#6

chars are only really used when you know the value is going to be between 0 and 255. So yeah, shouldn't be used for functions like gettime.

Small improvements:
PHP Code:
new SpamCount[MAX_PLAYERS char], ChatSpamTime[MAX_PLAYERS];

AntiSpam(playerid)
{
    new 
time gettime();
    if((
time ChatSpamTime[playerid]) < || !ChatSpamTime[playerid])
    {
        
ChatSpamTime[playerid] = time;
        switch(++
SpamCount{playerid})
        {
            case 
3:
            {
                new 
msg[75];
                
SendClientMessage(playerid0xFFFFFFFF"[Anti-Spam]: Warning you are one message away from being muted!");
                
format(msgsizeof(msg), "[Flood Control] - %s has been warned for flooding"GetName(playerid));
                
ABroadCast(COLOR_ADMINmsg1);
            }
            case 
4:
            {
                new 
msg[75];
                
format(msgsizeof(msg), "[Anti-Spam]: %s has been muted for 5 minutes! (Reason: Spam)"GetName(playerid));
                
SendClientMessageToAll(0xFFFFFFFFmsg);
                
SendClientMessage(playeridCOLOR_GREEN"You have received your final warning! You are now muted");
                
PlayerInfo[playerid][muted] = 1;
                print(
msg);
                
SetTimerEx("AutoUnMute"AutoUnmuteTime 60000false"i"playerid);
                
SpamCount{playerid} = 0;
                return 
0;
            }
        }
    }
    else
    {
        
SpamCount{playerid} = 0;
        
ChatSpamTime[playerid] = time;
    }
    return 
1;
}

public 
OnPlayerText(playeridtext[])
{
    if(!
AntiSpam(playerid)) return 0;
    
// Rest of OnPlayerText...

Reply


Messages In This Thread
Help Please - by Tass007 - 09.09.2016, 09:46
Re: Anti Spam help - by Tass007 - 10.09.2016, 06:12
Re: Anti Spam help - by jlalt - 10.09.2016, 07:27
Re: Anti Spam help - by Tass007 - 10.09.2016, 07:52
Re: Anti Spam help - by jlalt - 10.09.2016, 08:08
Re: Anti Spam help - by Threshold - 10.09.2016, 08:20

Forum Jump:


Users browsing this thread: 1 Guest(s)