Anti Spam help
#3

try this function, also use char var in it so you will save more memory usage.
also you don't need "stock" in this function.
PHP Code:
new SpamCount[MAX_PLAYERS char], ChatSpamTime[MAX_PLAYERS char];
AntiSpam(playerid)
{
    new 
msg[145];
    if((
gettime()-ChatSpamTime{playerid}) > || !ChatSpamTime{playerid})
    {
        
SpamCount{playerid} = 1;
        
ChatSpamTime{playerid} = gettime();
    }
    else
    {
        
SpamCount{playerid}++;
        switch(
SpamCount{playerid})
        {
            case 
2:
            {
                
ChatSpamTime{playerid} = gettime(); // <- update the time!
            
}
            case 
3:
            {
                
SendClientMessage(playerid0xFFFFFF"[Anti-Spam]: Warning you are one message away from being muted!");
                
format(msg,sizeof(msg),"[Flood Control] - %s has been warned for flooding",GetName(playerid));
                
ABroadCast(COLOR_ADMIN,msg,1);
                
ChatSpamTime{playerid} = gettime();
            }
            case 
4..99:
            {
                
format(msgsizeof(msg), "[Anti-Spam]: %s has been muted for 5 minutes! (Reason: Spam)"GetName(playerid));
                
SendClientMessageToAll(0xFFFFFFmsg);
                
SendClientMessage(playerid,COLOR_GREEN,"You have received your final warning! You are now muted");
                
PlayerInfo[playerid][muted] = 1;
                print(
msg);
                
SetTimerEx("AutoUnMute",AutoUnmuteTime*60000,false,"i",playerid);
                
ChatSpamTime{playerid} = 0;
                
SpamCount{playerid} = 0;
            }
        }
    }
    return 
1;

Char: https://sampwiki.blast.hk/wiki/Keywords:Operators#char
Stock: https://sampforum.blast.hk/showthread.php?tid=570635

also be sure to do
PHP Code:
    ChatSpamTime{playerid} = 0;
    
SpamCount{playerid} = 0
at onplayerconnect callback.
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)