AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] How to set a time interval (https://forums.alliedmods.net/showthread.php?t=229926)

wAyz 11-17-2013 02:37

[HELP] How to set a time interval
 
Hello,

This morning I've quickly created a little plugin:

Code:

#include <amxmodx>
#include <engine>

public plugin_init()
{
    register_plugin("Chat-Abuse Punisher","0.01","wayz")
   
    register_clcmd("say", "CmdSpam")
}

public CmdSpam(id)
{
    new said[192]
    read_args(said,192)
    new name[32]
    get_user_name(id, name, 31)
   
    if( ( containi(said, "TEST") != -1 ) )
    {
        server_cmd("amx_ban %s 5 Spam", name)
    }
}

Now I would like to set a time interval for let's say 5 minutes, basically if you say "TEST"
more than one time in those 5 minutes, you will get banned. Unfortunately, I didn't find a method to create this yet.

ConnorMcLeod 11-17-2013 02:54

Re: [HELP] How to set a time interval
 
See default plugin antiflood, it does exactly what you want.
But your plugin is NOT about name change, it is about chat abuse.

wAyz 11-17-2013 02:55

Re: [HELP] How to set a time interval
 
Thanks, I'm gonna try.

Edit: I have now imported the things out of antiflood.sma but I can't really set
a definite time of 5 minutes. Tried many things and it gags me kinda randomly.
For example I set the amx_namespam_time to "300" and right after I connect I can
"SPAM" 3-4 times without any gag. Then I get gagged. Usually I should only be able to say
it one time, then 2nd time -> gag.

Code:

#include <amxmodx>
#include <engine>

new Float:g_Flooding[33] = {0.0, ...}
new g_Flood[33] = {0, ...}

new amx_namespam_time;

public plugin_init()
{
    register_plugin("Chat-Abuse Punisher","0.01","wayz")
   
    register_clcmd("say", "CmdSpam")
    register_clcmd("say_team", "CmdSpam")
   
    amx_namespam_time=register_cvar("amx_namespam_time", "300")
}

public CmdSpam(id)
{
    new Float:maxChat = get_pcvar_float(amx_namespam_time)
    new said[192]
    read_args(said,192)
    new name[32]
    get_user_name(id, name, 31)
   
   
    if (maxChat)
    {
        new Float:nexTime = get_gametime()
       
        if (g_Flooding[id] > nexTime)
        {
        if (g_Flood[id] >= 3)
        {
        if( ( containi(said, "SPAM") != -1 ) )
        {
            server_cmd("amx_gag %s 1", name)
        }
        g_Flooding[id] = nexTime + maxChat + 3
        }
        g_Flood[id]++
        }
        else if (g_Flood[id])
        {
                g_Flood[id]--
        }
       
        g_Flooding[id] = nexTime + maxChat
    }
}



All times are GMT -4. The time now is 23:19.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.