View Single Post
ZaX
Senior Member
Join Date: Jan 2015
Old 11-12-2019 , 07:37   Re: [REQ] Anti Chat Flood
Reply With Quote #5

PHP Code:
 #include <amxmodx>

//Uncomment the line bellow to avoid chat duplicates
//#define AVOID_DUPLICATES 

#define SPAM_MAXCOUNT 4
#define BLOCK_DURATION 30
#define CHAT_DELAY 1.5

new Float:g_flChatDelay[33], bool:g_bMuted[33], g_iCount[33]

#if defined AVOID_DUPLICATES
new g_MsgSay
#endif

public plugin_init()
{
    
register_plugin("ANTI CHAT SPAMMER""1.0""ZinoZack47")
    
register_clcmd("say""HookSay")
    
register_clcmd("say_team""HookSay")

    
#if defined AVOID_DUPLICATES
    
g_MsgSay get_user_msgid ("SayText")
    
register_message(g_MsgSay"avoid_duplicated")
    
#endif
}

#if defined AVOID_DUPLICATES
public avoid_duplicated(MsgIdMsgDestReceiver)
    return 
PLUGIN_HANDLED
#endif

public HookSay(id)
{
    if (
g_bMuted[id])
        return 
PLUGIN_HANDLED

    
static szMsg[192]
    
read_args(szMsgcharsmax(szMsg))
    
remove_quotes(szMsg)

    if(!
szMsg[0] || szMsg[0] == '/' || szMsg[0] == '@' || szMsg[0] == '!')
        return 
PLUGIN_CONTINUE;

    if (
get_gametime() - g_flChatDelay[id] < CHAT_DELAY)
    {
        
g_flChatDelay[id] = get_gametime()
        
g_iCount[id]++
        if(
g_iCount[id] > SPAM_MAXCOUNT)
        {
            
client_print(idprint_center"You have been muted for %d Seconds"BLOCK_DURATION)
            
g_bMuted[id] = true
            set_task
(float(BLOCK_DURATION), "UnmutePlayer"id)
            return 
PLUGIN_HANDLED
        
}
    }

    return 
PLUGIN_CONTINUE
}

public 
UnmutePlayer(id)
{
    
g_bMuted[id] = false
    g_iCount
[id] = 0
}

public 
client_disconnected(id)
{
    
g_bMuted[id] = false
    g_iCount
[id] = 0
    g_flChatDelay
[id] = 0.0

Try this
Im not the author

Last edited by ZaX; 11-12-2019 at 07:37.
ZaX is offline