-=惩罚频繁连接者=-
#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
new g_lastping, g_fluxcounter, g_losscounter, g_immune
// 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
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) check_flags(id)
}
public client_putinserver(id)
{
set_task(16.0, "join_message", id+TASK_JOINMSG)
g_connected = 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 = 0
g_losscounter = 0
g_lastping = 0
g_immune = 0
g_connected = false
}
public do_checks()
{
static id, ping, loss, name, auth, userid, minutes
for (id = 1; id <= g_maxplayers; id++)
{
if (!g_connected || g_immune)
continue;
get_user_ping(id, ping, loss)
if (loss > g_maxloss)
g_losscounter++
else if (g_losscounter > 0)
g_losscounter--
if (g_losscounter >= 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, " %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, " %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, " %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, " %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, " %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) > g_maxflux)
g_fluxcounter++
else if (g_fluxcounter > 0)
g_fluxcounter--
if (g_fluxcounter >= 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, " %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, " %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, " %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, " %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, " %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 = ping
}
}
public join_message(taskid)
{
client_print(ID_JOINMSG, print_chat, " %L", ID_JOINMSG, "JOIN_MSG", g_maxflux, g_maxloss)
}
check_flags(id)
{
g_immune = get_user_flags(id) & g_immunityflags
}
语言数据
lame_connection_punisher.txt
JOIN_MSG = 玩家重入都將受到懲罰(平流量限制: %d ,限制: %d )。
MSG_ALL_KICK = %s 已踢出因重入本伺服器
MSG_ALL_BAN = %s 已禁止 %d 分鐘因重入本伺服器
MSG_ALL_PBAN = %s 被永久禁止因重入本伺服器。
MSG_TARGET_LOSS = 您因重入本伺服器而失去很多數據包
MSG_TARGET_FLUX = 您的廷遲不太穩定. hebe!!!!!!!!!!!!!!!!!!!! :victory: 。。。。。。。。 :D
有个reme的插件可以达到这个功能
还可以刷新分数不用重进服务器 我只是发现这个插件源码!故发到这里供大家研究随便赚点值 没有玩家连接次数过于频繁会提示"连接过于频繁,稍候重试"这种的...不是retry 这种的 没有玩家连接次数过于频繁会提示"连接过于频繁,稍候重试"这种的...不是retry 这种的
小白 发表于 2009-4-2 14:20 http://www.dt-club.net/forum/images/common/back.gif
官网上好像看到过这种插件。 作用不大。。 没什么意思 晕 直接把源码弄上来了。。。
页:
[1]
2