Raised This Month: $ Target: $400
 0% 

[HELP] How to set a time interval


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wAyz
Senior Member
Join Date: Feb 2010
Location: Germany
Old 11-17-2013 , 02:37   [HELP] How to set a time interval
Reply With Quote #1

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.

Last edited by wAyz; 11-17-2013 at 03:00.
wAyz is offline
Old 11-17-2013, 02:42
LordOfNothing
This message has been deleted by ConnorMcLeod. Reason: DON'T
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-17-2013 , 02:54   Re: [HELP] How to set a time interval
Reply With Quote #3

See default plugin antiflood, it does exactly what you want.
But your plugin is NOT about name change, it is about chat abuse.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 11-17-2013 at 02:55.
ConnorMcLeod is offline
wAyz
Senior Member
Join Date: Feb 2010
Location: Germany
Old 11-17-2013 , 02:55   Re: [HELP] How to set a time interval
Reply With Quote #4

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
     }
}

Last edited by wAyz; 11-17-2013 at 07:21.
wAyz is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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