Code: Select all
#include <amxmodx>
#include <orpheu>
#define PLUGIN "Anti flood"
#define VERSION "1.0"
#define AUTHOR "kanagava"
new time_last_conn
new ip_old[256]
new ip_warn[256]
new Msg[256]
new OrpheuHook:handlePrintf
new warn
new old_time
new registered
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
set_task(5.0, "regfunctions")
}
public regfunctions()
{
server_cmd("mp_logecho 1")
server_cmd("log on")
OrpheuRegisterHook(OrpheuGetFunction("SV_ConnectClient"),"OnSV_ConnectClientPre", OrpheuHookPre)
OrpheuRegisterHook(OrpheuGetFunction("SV_ConnectClient"),"OnSV_ConnectClientPost", OrpheuHookPost)
}
public OrpheuHookReturn:OnSV_ConnectClientPre()
{
registered=0
if(get_systime()-old_time <= 2)
{
handlePrintf = OrpheuRegisterHook( OrpheuGetFunction( "Con_Printf" ), "Con_Printf" , OrpheuHookPre);
registered=1
}
old_time=get_systime()
return OrpheuIgnored;
}
public OrpheuHookReturn:OnSV_ConnectClientPost()
{
if(registered)
{
OrpheuUnregisterHook(handlePrintf)
}
return OrpheuIgnored;
}
public OrpheuHookReturn:Con_Printf(const a[], const message[] )
{
registered=1
if (containi(message,"^" connected, address ^"")!=-1)
{
new len=255
new temp_right[256],temp_left[256],conn_ip[256]
formatex( Msg,charsmax( Msg ),"%s", message );
split(Msg, temp_left, len, temp_right, len, "^" connected, address ^"")
strtok(temp_right, conn_ip, len, temp_right, len, ':')
if (equal(conn_ip,ip_old) && !equal(conn_ip,"") && ((get_systime()-time_last_conn)<2))
{
warn=warn+1
if(warn>1 && equal(conn_ip,ip_warn))
{
log_amx("[NOFLOOD] Connection flood detected from ip %s",ip_old)
server_cmd("addip 120.0 %s",ip_old)
}
ip_warn=conn_ip
}
else
{
warn=0
}
ip_old=conn_ip
time_last_conn=get_systime()
}
return OrpheuIgnored;
}
Code: Select all
L 08/10/2012 - 17:18:54: Start of error session.
L 08/10/2012 - 17:18:54: Info (map "deathrun_kolor_V2") (file "addons/amxmodx/logs/error_20120810.log")
L 08/10/2012 - 17:18:54: [ORPHEU] Function "SV_ConnectClient" not found
L 08/10/2012 - 17:18:54: [AMXX] Displaying debug trace (plugin "noflood.amxx")
L 08/10/2012 - 17:18:54: [AMXX] Run time error 10: native error (native "OrpheuGetFunction")
L 08/10/2012 - 17:18:54: [AMXX] [0] noflood.sma::regfunctions (line 25)
L 08/10/2012 - 17:50:33: Start of error session.
L 08/10/2012 - 17:50:33: Info (map "deathrun_forest") (file "addons/amxmodx/logs/error_20120810.log")
L 08/10/2012 - 17:50:33: [ORPHEU] Function "SV_ConnectClient" not found
L 08/10/2012 - 17:50:33: [AMXX] Displaying debug trace (plugin "noflood.amxx")
L 08/10/2012 - 17:50:33: [AMXX] Run time error 10: native error (native "OrpheuGetFunction")
L 08/10/2012 - 17:50:33: [AMXX] [0] noflood.sma::regfunctions (line 25)
L 08/10/2012 - 18:09:34: Start of error session.
L 08/10/2012 - 18:09:34: Info (map "deathrun_PiNk_e") (file "addons/amxmodx/logs/error_20120810.log")
L 08/10/2012 - 18:09:34: [ORPHEU] Function "SV_ConnectClient" not found
L 08/10/2012 - 18:09:34: [AMXX] Displaying debug trace (plugin "noflood.amxx")
L 08/10/2012 - 18:09:34: [AMXX] Run time error 10: native error (native "OrpheuGetFunction")
L 08/10/2012 - 18:09:34: [AMXX] [0] noflood.sma::regfunctions (line 25)
L 08/10/2012 - 18:27:24: Start of error session.
L 08/10/2012 - 18:27:24: Info (map "deathrun_arctic") (file "addons/amxmodx/logs/error_20120810.log")
L 08/10/2012 - 18:27:24: [ORPHEU] Function "SV_ConnectClient" not found
L 08/10/2012 - 18:27:24: [AMXX] Displaying debug trace (plugin "noflood.amxx")
L 08/10/2012 - 18:27:24: [AMXX] Run time error 10: native error (native "OrpheuGetFunction")
L 08/10/2012 - 18:27:24: [AMXX] [0] noflood.sma::regfunctions (line 25)
L 08/10/2012 - 18:45:09: Start of error session.
L 08/10/2012 - 18:45:09: Info (map "deathrun_amigosano") (file "addons/amxmodx/logs/error_20120810.log")
L 08/10/2012 - 18:45:09: [ORPHEU] Function "SV_ConnectClient" not found
L 08/10/2012 - 18:45:09: [AMXX] Displaying debug trace (plugin "noflood.amxx")
L 08/10/2012 - 18:45:09: [AMXX] Run time error 10: native error (native "OrpheuGetFunction")
L 08/10/2012 - 18:45:09: [AMXX] [0] noflood.sma::regfunctions (line 25)
L 08/10/2012 - 19:03:20: Start of error session.
L 08/10/2012 - 19:03:20: Info (map "deathrun_grass") (file "addons/amxmodx/logs/error_20120810.log")
L 08/10/2012 - 19:03:20: [ORPHEU] Function "SV_ConnectClient" not found
L 08/10/2012 - 19:03:20: [AMXX] Displaying debug trace (plugin "noflood.amxx")
L 08/10/2012 - 19:03:20: [AMXX] Run time error 10: native error (native "OrpheuGetFunction")
L 08/10/2012 - 19:03:20: [AMXX] [0] noflood.sma::regfunctions (line 25)