Added anti-flood plugin.
Added anti-flood plugin.
Added some missing includes to sourcemod.inc
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/plugins/antiflood.sp Thu Jun 07 07:22:19 2007 +0000
1.3 @@ -0,0 +1,87 @@
1.4 +/**
1.5 + * antiflood.sp
1.6 + * Protects against chat flooding.
1.7 + * This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
1.8 + *
1.9 + * This program is free software; you can redistribute it and/or
1.10 + * modify it under the terms of the GNU General Public License
1.11 + * as published by the Free Software Foundation; either version 2
1.12 + * of the License, or (at your option) any later version.
1.13 + *
1.14 + * This program is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 + * GNU General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU General Public License
1.20 + * along with this program; if not, write to the Free Software
1.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1.22 + *
1.23 + * Version: $Id$
1.24 + */
1.25 +
1.26 +#include <sourcemod>
1.27 +
1.28 +#pragma semicolon 1
1.29 +
1.30 +public Plugin:myinfo =
1.31 +{
1.32 + name = "Anti-Flood",
1.33 + author = "AlliedModders LLC",
1.34 + description = "Protects against chat flooding",
1.35 + version = SOURCEMOD_VERSION,
1.36 + url = "http://www.sourcemod.net/"
1.37 +};
1.38 +
1.39 +new Float:g_LastTime[MAXPLAYERS + 1] = {0.0, ...}; /* Last time player used say or say_team */
1.40 +new g_FloodTokens[MAXPLAYERS + 1] = {0, ...}; /* Number of flood tokens player has */
1.41 +
1.42 +new Handle:sm_flood_time; /* Handle to sm_flood_time convar */
1.43 +
1.44 +public OnPluginStart()
1.45 +{
1.46 + LoadTranslations("core.cfg");
1.47 +
1.48 + RegConsoleCmd("say", CheckChatFlood);
1.49 + RegConsoleCmd("say_team", CheckChatFlood);
1.50 + sm_flood_time = CreateConVar("sm_flood_time", "0.75", "Amount of time allowed between chat messages");
1.51 +}
1.52 +
1.53 +public Action:CheckChatFlood(client, args)
1.54 +{
1.55 + /* Chat from server console shouldn't be checked for flooding */
1.56 + if (client == 0)
1.57 + {
1.58 + return Plugin_Continue;
1.59 + }
1.60 +
1.61 + new Float:maxChat = GetConVarFloat(sm_flood_time);
1.62 +
1.63 + if (maxChat > 0.0)
1.64 + {
1.65 + new Float:curTime = GetGameTime();
1.66 +
1.67 + if (g_LastTime[client] > curTime)
1.68 + {
1.69 + /* If player has 3 or more flood tokens, block their message */
1.70 + if (g_FloodTokens[client] >= 3)
1.71 + {
1.72 + PrintToChat(client, "[SM] %t", "Flooding the server");
1.73 + g_LastTime[client] = curTime + maxChat + 3.0;
1.74 +
1.75 + return Plugin_Stop;
1.76 + }
1.77 +
1.78 + /* Add one flood token when player goes over chat time limit */
1.79 + g_FloodTokens[client]++;
1.80 + } else if (g_FloodTokens[client]) {
1.81 + /* Remove one flood token when player chats within time limit (slow decay) */
1.82 + g_FloodTokens[client]--;
1.83 + }
1.84 +
1.85 + /* Store last time of chat usage */
1.86 + g_LastTime[client] = curTime + maxChat;
1.87 + }
1.88 +
1.89 + return Plugin_Continue;
1.90 +}
2.1 --- a/plugins/basecommands.sp Thu Jun 07 07:11:37 2007 +0000
2.2 +++ b/plugins/basecommands.sp Thu Jun 07 07:22:19 2007 +0000
2.3 @@ -1,6 +1,6 @@
2.4 /**
2.5 - * admincmds-basic.sp
2.6 - * Manages the standard flat files for admins. This is the file to compile.
2.7 + * basecommands.sp
2.8 + * Implements basic admin commands.
2.9 * This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
2.10 *
2.11 * This program is free software; you can redistribute it and/or
2.12 @@ -16,10 +16,14 @@
2.13 * You should have received a copy of the GNU General Public License
2.14 * along with this program; if not, write to the Free Software
2.15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2.16 + *
2.17 + * Version: $Id$
2.18 */
2.19
2.20 #include <sourcemod>
2.21
2.22 +#pragma semicolon 1
2.23 +
2.24 public Plugin:myinfo =
2.25 {
2.26 name = "Basic Commands",
2.27 @@ -63,7 +67,7 @@
2.28
2.29 GetClientName(clients[0], name, sizeof(name));
2.30
2.31 - decl String:reason[256]
2.32 + decl String:reason[256];
2.33 if (args < 2)
2.34 {
2.35 /* Safely null terminate */
3.1 --- a/plugins/include/keyvalues.inc Thu Jun 07 07:11:37 2007 +0000
3.2 +++ b/plugins/include/keyvalues.inc Thu Jun 07 07:22:19 2007 +0000
3.3 @@ -332,4 +332,4 @@
3.4 * @return Number of non-root nodes in the jump stack.
3.5 * @error Invalid Handle.
3.6 */
3.7 -native KvNodesInStack(Handle:kv);
3.8 \ No newline at end of file
3.9 +native KvNodesInStack(Handle:kv);
4.1 --- a/plugins/include/sourcemod.inc Thu Jun 07 07:11:37 2007 +0000
4.2 +++ b/plugins/include/sourcemod.inc Thu Jun 07 07:22:19 2007 +0000
4.3 @@ -39,14 +39,16 @@
4.4 #include <timers>
4.5 #include <admin>
4.6 #include <dbi>
4.7 +#include <lang>
4.8 #include <sorting>
4.9 +#include <textparse>
4.10 #include <clients>
4.11 #include <console>
4.12 #include <events>
4.13 #include <bitbuffer>
4.14 #include <usermessages>
4.15 +#include <keyvalues>
4.16 #include <menus>
4.17 -#include <lang>
4.18 #include <halflife>
4.19
4.20 /**
5.1 --- a/translations/core.cfg Thu Jun 07 07:11:37 2007 +0000
5.2 +++ b/translations/core.cfg Thu Jun 07 07:22:19 2007 +0000
5.3 @@ -36,4 +36,9 @@
5.4 "#format" "{1:s}"
5.5 "en" "Kicked player '{1}'"
5.6 }
5.7 +
5.8 + "Flooding the server"
5.9 + {
5.10 + "en" "You are flooding the server!"
5.11 + }
5.12 }