Anti Spam help
#1

Hey guys, I got this script. It complies fine but there's a bug that I'm not quite sure how to fix.
When you spam the chat so say I repeat the message "Bob" 4 times I get the message "[Anti-Spam]: Warning you are one message away from being muted!" If you message Bob 1 more time in 4 seconds you get muted. That works fine. However if you send "Bob" 4 times after the 4 seconds is over you don't get muted and never can unless you reconnect. So the script isn't resetting itself properly. Not sure how to do it.

PHP Code:
stock AntiSpam(playerid)
{
    new 
msg[145];
    
SpamCount[playerid]++;
    switch(
SpamCount[playerid])
    {
        case 
1:
        {
            
ChatSpamTime[playerid][0]=gettime();
        }
        case 
2:
        {
            if((
gettime()-ChatSpamTime[playerid][0])<4)
            {
                
ChatSpamTime[playerid][1]=gettime();
            }
            else 
SpamCount[playerid]=0;
        }
        case 
3:
        {
            if((
gettime()-ChatSpamTime[playerid][1])<4)
            {
                
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][2]=gettime();
            }
            else 
SpamCount[playerid]=0;
        }
        case 
4..50:
        {
            if((
gettime()-ChatSpamTime[playerid][2])<4)
            {
                
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);
            }
        }
    }
    return 
1;

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)