Update checkout-deps script for Dota 2 on Linux and Mac OS X.
3 * =============================================================================
4 * SourceMod Anti-Flood Plugin
5 * Protects against chat flooding.
7 * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
8 * =============================================================================
10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License, version 3.0, as published by the
12 * Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
22 * As a special exception, AlliedModders LLC gives you permission to link the
23 * code of this program (as well as its derivative works) to "Half-Life 2," the
24 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
25 * by the Valve Corporation. You must obey the GNU General Public License in
26 * all respects for all other code used. Additionally, AlliedModders LLC grants
27 * this exception to all derivative works. AlliedModders LLC defines further
28 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
29 * or <http://www.sourcemod.net/license.php>.
38 public Plugin:myinfo =
41 author = "AlliedModders LLC",
42 description = "Protects against chat flooding",
43 version = SOURCEMOD_VERSION,
44 url = "http://www.sourcemod.net/"
47 new Float:g_LastTime[MAXPLAYERS + 1] = {0.0, ...}; /* Last time player used say or say_team */
48 new g_FloodTokens[MAXPLAYERS + 1] = {0, ...}; /* Number of flood tokens player has */
50 new Handle:sm_flood_time; /* Handle to sm_flood_time convar */
52 public OnPluginStart()
54 sm_flood_time = CreateConVar("sm_flood_time", "0.75", "Amount of time allowed between chat messages");
57 public OnClientPutInServer(client)
59 g_LastTime[client] = 0.0;
60 g_FloodTokens[client] = 0;
65 public bool:OnClientFloodCheck(client)
67 max_chat = GetConVarFloat(sm_flood_time);
70 || CheckCommandAccess(client, "sm_flood_access", ADMFLAG_ROOT, true))
75 if (g_LastTime[client] >= GetGameTime())
77 /* If player has 3 or more flood tokens, block their message */
78 if (g_FloodTokens[client] >= 3)
87 public OnClientFloodResult(client, bool:blocked)
90 || CheckCommandAccess(client, "sm_flood_access", ADMFLAG_ROOT, true))
95 new Float:curTime = GetGameTime();
96 new Float:newTime = curTime + max_chat;
98 if (g_LastTime[client] >= curTime)
100 /* If the last message was blocked, update their time limit */
105 /* Add one flood token when player goes over chat time limit */
106 else if (g_FloodTokens[client] < 3)
108 g_FloodTokens[client]++;
111 else if (g_FloodTokens[client] > 0)
113 /* Remove one flood token when player chats within time limit (slow decay) */
114 g_FloodTokens[client]--;
117 g_LastTime[client] = newTime;