|
#include <amxmodx>
const TASK_JOINMSG = 100
const TASK_DOCHECKS = 200
#define ID_JOINMSG (taskid-TASK_JOINMSG)
new cvar_flux, cvar_loss, cvar_punishment, cvar_bantime, cvar_immunity
new g_maxflux, g_maxloss, g_immunityflags, g_maxplayers, g_connected[33]
new g_lastping[33], g_fluxcounter[33], g_losscounter[33], g_immune[33]
// I wouldn't recommend lowering these unless
// you wanna pick up a lot of false positives
const Float:CHECK_FREQ = 5.0
const FLUX_TESTS = 12
const LOSS_TESTS = 12
public plugin_init()
{
register_plugin("Lame Connection Punisher", "1.1b", "MeRcyLeZZ")
register_dictionary("lame_connection_punisher.txt")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
cvar_flux = register_cvar("lcp_flux_limit", "100")
cvar_loss = register_cvar("lcp_loss_limit", "10")
cvar_punishment = register_cvar("lcp_punishment", "0")
cvar_bantime = register_cvar("lcp_ban_time", "5")
cvar_immunity = register_cvar("lcp_immunity", "a")
g_maxplayers = get_maxplayers()
}
public plugin_cfg()
{
// Cache CVARs after configs are loaded
set_task(0.5, "event_round_start")
// Start checking players
set_task(CHECK_FREQ, "do_checks", TASK_DOCHECKS, _, _, "b")
}
public event_round_start()
{
// Cache CVARs
new flags[6]
get_pcvar_string(cvar_immunity, flags, charsmax(flags))
g_immunityflags = read_flags(flags)
g_maxflux = get_pcvar_num(cvar_flux)
g_maxloss = get_pcvar_num(cvar_loss)
// Check flags again for all players
for (new id = 1; id <= g_maxplayers; id++)
if (g_connected[id]) check_flags(id)
}
public client_putinserver(id)
{
set_task(16.0, "join_message", id+TASK_JOINMSG)
g_connected[id] = true
}
public client_authorized(id)
{
check_flags(id)
}
public client_infochanged(id)
{
check_flags(id)
}
public client_disconnect(id)
{
remove_task(id+TASK_JOINMSG)
g_fluxcounter[id] = 0
g_losscounter[id] = 0
g_lastping[id] = 0
g_immune[id] = 0
g_connected[id] = false
}
public do_checks()
{
static id, ping, loss, name[32], auth[32], userid, minutes
for (id = 1; id <= g_maxplayers; id++)
{
if (!g_connected[id] || g_immune[id])
continue;
get_user_ping(id, ping, loss)
if (loss > g_maxloss)
g_losscounter[id]++
else if (g_losscounter[id] > 0)
g_losscounter[id]--
if (g_losscounter[id] >= LOSS_TESTS)
{
get_user_name(id, name , sizeof name - 1)
userid = get_user_userid(id)
switch (get_pcvar_num(cvar_punishment))
{
case 1:
{
get_user_authid(id, auth, sizeof auth - 1)
minutes = get_pcvar_num(cvar_bantime)
if (minutes > 0)
{
client_print(0, print_chat, "[AMXX] %L", LANG_PLAYER, "MSG_ALL_BAN", name, minutes)
log_amx("%L", LANG_SERVER, "MSG_ALL_BAN", name, minutes)
server_cmd("kick #%d ^"%L^";wait;banid %d ^"%s^";wait;writeid", userid, id, "MSG_TARGET_LOSS", minutes, auth)
}
else
{
client_print(0, print_chat, "[AMXX] %L", LANG_PLAYER, "MSG_ALL_PBAN", name)
log_amx("%L", LANG_SERVER, "MSG_ALL_PBAN", name)
server_cmd("kick #%d ^"%L^";wait;banid 0 ^"%s^";wait;writeid", userid, id, "MSG_TARGET_LOSS", auth)
}
}
case 2:
{
get_user_ip(id, auth, sizeof auth - 1, 1)
minutes = get_pcvar_num(cvar_bantime)
if (minutes > 0)
{
client_print(0, print_chat, "[AMXX] %L", LANG_PLAYER, "MSG_ALL_BAN", name, minutes)
log_amx("%L", LANG_SERVER, "MSG_ALL_BAN", name, minutes)
server_cmd("kick #%d ^"%L^";wait;addip %d ^"%s^";wait;writeip", userid, id, "MSG_TARGET_LOSS", minutes, auth)
}
else
{
client_print(0, print_chat, "[AMXX] %L", LANG_PLAYER, "MSG_ALL_PBAN", name)
log_amx("%L", LANG_SERVER, "MSG_ALL_PBAN", name)
server_cmd("kick #%d ^"%L^";wait;addip 0 ^"%s^";wait;writeip", userid, id, "MSG_TARGET_LOSS", auth)
}
}
default:
{
client_print(0, print_chat, "[AMXX] %L", LANG_PLAYER, "MSG_ALL_KICK", name)
log_amx("%L", LANG_SERVER, "MSG_ALL_KICK", name)
server_cmd("kick #%d ^"%L^"", userid, id, "MSG_TARGET_LOSS")
}
}
continue;
}
if (abs(ping - g_lastping[id]) > g_maxflux)
g_fluxcounter[id]++
else if (g_fluxcounter[id] > 0)
g_fluxcounter[id]--
if (g_fluxcounter[id] >= FLUX_TESTS)
{
get_user_name(id, name , sizeof name - 1)
userid = get_user_userid(id)
switch (get_pcvar_num(cvar_punishment))
{
case 1:
{
get_user_authid(id, auth, sizeof auth - 1)
minutes = get_pcvar_num(cvar_bantime)
if (minutes > 0)
{
client_print(0, print_chat, "[AMXX] %L", LANG_PLAYER, "MSG_ALL_BAN", name, minutes)
log_amx("%L", LANG_SERVER, "MSG_ALL_BAN", name, minutes)
server_cmd("kick #%d ^"%L^";wait;banid %d ^"%s^";wait;writeid", userid, id, "MSG_TARGET_FLUX", minutes, auth)
}
else
{
client_print(0, print_chat, "[AMXX] %L", LANG_PLAYER, "MSG_ALL_PBAN", name)
log_amx("%L", LANG_SERVER, "MSG_ALL_PBAN", name)
server_cmd("kick #%d ^"%L^";wait;banid 0 ^"%s^";wait;writeid", userid, id, "MSG_TARGET_FLUX", auth)
}
}
case 2:
{
get_user_ip(id, auth, sizeof auth - 1, 1)
minutes = get_pcvar_num(cvar_bantime)
if (minutes > 0)
{
client_print(0, print_chat, "[AMXX] %L", LANG_PLAYER, "MSG_ALL_BAN", name, minutes)
log_amx("%L", LANG_SERVER, "MSG_ALL_BAN", name, minutes)
server_cmd("kick #%d ^"%L^";wait;addip %d ^"%s^";wait;writeip", userid, id, "MSG_TARGET_FLUX", minutes, auth)
}
else
{
client_print(0, print_chat, "[AMXX] %L", LANG_PLAYER, "MSG_ALL_PBAN", name)
log_amx("%L", LANG_SERVER, "MSG_ALL_PBAN", name)
server_cmd("kick #%d ^"%L^";wait;addip 0 ^"%s^";wait;writeip", userid, id, "MSG_TARGET_FLUX", auth)
}
}
default:
{
client_print(0, print_chat, "[AMXX] %L", LANG_PLAYER, "MSG_ALL_KICK", name)
log_amx("%L", LANG_SERVER, "MSG_ALL_KICK", name)
server_cmd("kick #%d ^"%L^"", userid, id, "MSG_TARGET_FLUX")
}
}
continue;
}
g_lastping[id] = ping
}
}
public join_message(taskid)
{
client_print(ID_JOINMSG, print_chat, "[AMXX] %L", ID_JOINMSG, "JOIN_MSG", g_maxflux, g_maxloss)
}
check_flags(id)
{
g_immune[id] = get_user_flags(id) & g_immunityflags
}
语言数据
lame_connection_punisher.txt
[cn]
JOIN_MSG = 玩家重入都將受到懲罰(平流量限制: %d ,限制: %d )。
MSG_ALL_KICK = %s 已踢出因重入本伺服器
MSG_ALL_BAN = %s 已禁止 %d 分鐘因重入本伺服器
MSG_ALL_PBAN = %s 被永久禁止因重入本伺服器。
MSG_TARGET_LOSS = 您因重入本伺服器而失去很多數據包
MSG_TARGET_FLUX = 您的廷遲不太穩定. |
|