From 7db35f0d9764430d34d53844e8f5eb0933527e16 Mon Sep 17 00:00:00 2001 From: connorr Date: Wed, 31 Jul 2013 17:01:55 +0200 Subject: [PATCH] Implement cooldown on say_team @ to prevent admin's client get overflowed if executed a couple of times (bug 5815, r=arkshine) --- plugins/adminchat.sma | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/plugins/adminchat.sma b/plugins/adminchat.sma index 86465013..229c797e 100755 --- a/plugins/adminchat.sma +++ b/plugins/adminchat.sma @@ -44,8 +44,12 @@ new g_Values[MAX_CLR][] = {{255, 255, 255}, {255, 0, 0}, {0, 255, 0}, {0, 0, 255 new Float:g_Pos[4][] = {{0.0, 0.0}, {0.05, 0.55}, {-1.0, 0.2}, {-1.0, 0.7}} new amx_show_activity; +new amx_flood_time; new g_AdminChatFlag = ADMIN_CHAT; +new Float:g_Flooding[33] = {0.0, ...} +new g_Flood[33] = {0, ...} + public plugin_init() { new admin_chat_id @@ -53,6 +57,7 @@ public plugin_init() register_plugin("Admin Chat", AMXX_VERSION_STR, "AMXX Dev Team") register_dictionary("adminchat.txt") register_dictionary("common.txt") + register_dictionary("antiflood.txt") register_clcmd("say", "cmdSayChat", ADMIN_CHAT, "@[@|@|@][w|r|g|b|y|m|c] - displays hud message") register_clcmd("say_team", "cmdSayAdmin", 0, "@ - displays message to admins") register_concmd("amx_say", "cmdSay", ADMIN_CHAT, " - sends message to all players") @@ -72,6 +77,19 @@ public plugin_init() get_concmd(admin_chat_id, str, 0, g_AdminChatFlag, str, 0, -1) } +public plugin_cfg() +{ + // check if cvar amx_flood_time exists (created by antiflood plugin) + + amx_flood_time = get_cvar_pointer("amx_flood_time"); + + if( !amx_flood_time ) + { + // else create it + amx_flood_time = register_cvar("amx_flood_time", "0.75"); + } +} + public cmdSayChat(id) { if (!access(id, g_AdminChatFlag)) @@ -182,6 +200,30 @@ public cmdSayAdmin(id) if (said[0] != '@') return PLUGIN_CONTINUE + + new Float:maxChat = get_pcvar_float(amx_flood_time) + + if (maxChat) + { + new Float:nexTime = get_gametime() + + if (g_Flooding[id] > nexTime) + { + if (g_Flood[id] >= 3) + { + client_print(id, print_notify, "** %L **", id, "STOP_FLOOD") + g_Flooding[id] = nexTime + maxChat + 3.0 + return PLUGIN_HANDLED + } + g_Flood[id]++ + } + else if (g_Flood[id]) + { + g_Flood[id]-- + } + + g_Flooding[id] = nexTime + maxChat + } new message[192], name[32], authid[32], userid new players[32], inum