Added check to make sure player are alive to perform sm_slap, sm_burn, sm_slay.
3 * Protects against chat flooding.
4 * This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 public Plugin:myinfo =
30 author = "AlliedModders LLC",
31 description = "Protects against chat flooding",
32 version = SOURCEMOD_VERSION,
33 url = "http://www.sourcemod.net/"
36 new Float:g_LastTime[MAXPLAYERS + 1] = {0.0, ...}; /* Last time player used say or say_team */
37 new g_FloodTokens[MAXPLAYERS + 1] = {0, ...}; /* Number of flood tokens player has */
39 new Handle:sm_flood_time; /* Handle to sm_flood_time convar */
41 public OnPluginStart()
43 LoadTranslations("antiflood.phrases");
45 RegConsoleCmd("say", CheckChatFlood);
46 RegConsoleCmd("say_team", CheckChatFlood);
47 sm_flood_time = CreateConVar("sm_flood_time", "0.75", "Amount of time allowed between chat messages");
50 public OnClientPutInServer(client)
52 g_LastTime[client] = 0.0;
53 g_FloodTokens[client] = 0;
56 public Action:CheckChatFlood(client, args)
58 /* Chat from server console shouldn't be checked for flooding */
61 return Plugin_Continue;
64 new Float:maxChat = GetConVarFloat(sm_flood_time);
68 new Float:curTime = GetGameTime();
70 if (g_LastTime[client] > curTime)
72 /* If player has 3 or more flood tokens, block their message */
73 if (g_FloodTokens[client] >= 3)
75 PrintToChat(client, "[SM] %t", "Flooding the server");
76 g_LastTime[client] = curTime + maxChat + 3.0;
81 /* Add one flood token when player goes over chat time limit */
82 g_FloodTokens[client]++;
83 } else if (g_FloodTokens[client]) {
84 /* Remove one flood token when player chats within time limit (slow decay) */
85 g_FloodTokens[client]--;
88 /* Store last time of chat usage */
89 g_LastTime[client] = curTime + maxChat;
92 return Plugin_Continue;