Added anti-flood plugin.
Added some missing includes to sourcemod.inc --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40919
This commit is contained in:
parent
0883cc8769
commit
f129a830b8
87
plugins/antiflood.sp
Normal file
87
plugins/antiflood.sp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/**
|
||||||
|
* antiflood.sp
|
||||||
|
* Protects against chat flooding.
|
||||||
|
* This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* Version: $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sourcemod>
|
||||||
|
|
||||||
|
#pragma semicolon 1
|
||||||
|
|
||||||
|
public Plugin:myinfo =
|
||||||
|
{
|
||||||
|
name = "Anti-Flood",
|
||||||
|
author = "AlliedModders LLC",
|
||||||
|
description = "Protects against chat flooding",
|
||||||
|
version = SOURCEMOD_VERSION,
|
||||||
|
url = "http://www.sourcemod.net/"
|
||||||
|
};
|
||||||
|
|
||||||
|
new Float:g_LastTime[MAXPLAYERS + 1] = {0.0, ...}; /* Last time player used say or say_team */
|
||||||
|
new g_FloodTokens[MAXPLAYERS + 1] = {0, ...}; /* Number of flood tokens player has */
|
||||||
|
|
||||||
|
new Handle:sm_flood_time; /* Handle to sm_flood_time convar */
|
||||||
|
|
||||||
|
public OnPluginStart()
|
||||||
|
{
|
||||||
|
LoadTranslations("core.cfg");
|
||||||
|
|
||||||
|
RegConsoleCmd("say", CheckChatFlood);
|
||||||
|
RegConsoleCmd("say_team", CheckChatFlood);
|
||||||
|
sm_flood_time = CreateConVar("sm_flood_time", "0.75", "Amount of time allowed between chat messages");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action:CheckChatFlood(client, args)
|
||||||
|
{
|
||||||
|
/* Chat from server console shouldn't be checked for flooding */
|
||||||
|
if (client == 0)
|
||||||
|
{
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
new Float:maxChat = GetConVarFloat(sm_flood_time);
|
||||||
|
|
||||||
|
if (maxChat > 0.0)
|
||||||
|
{
|
||||||
|
new Float:curTime = GetGameTime();
|
||||||
|
|
||||||
|
if (g_LastTime[client] > curTime)
|
||||||
|
{
|
||||||
|
/* If player has 3 or more flood tokens, block their message */
|
||||||
|
if (g_FloodTokens[client] >= 3)
|
||||||
|
{
|
||||||
|
PrintToChat(client, "[SM] %t", "Flooding the server");
|
||||||
|
g_LastTime[client] = curTime + maxChat + 3.0;
|
||||||
|
|
||||||
|
return Plugin_Stop;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add one flood token when player goes over chat time limit */
|
||||||
|
g_FloodTokens[client]++;
|
||||||
|
} else if (g_FloodTokens[client]) {
|
||||||
|
/* Remove one flood token when player chats within time limit (slow decay) */
|
||||||
|
g_FloodTokens[client]--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Store last time of chat usage */
|
||||||
|
g_LastTime[client] = curTime + maxChat;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* admincmds-basic.sp
|
* basecommands.sp
|
||||||
* Manages the standard flat files for admins. This is the file to compile.
|
* Implements basic admin commands.
|
||||||
* This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
|
* This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
@ -16,10 +16,14 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* Version: $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sourcemod>
|
#include <sourcemod>
|
||||||
|
|
||||||
|
#pragma semicolon 1
|
||||||
|
|
||||||
public Plugin:myinfo =
|
public Plugin:myinfo =
|
||||||
{
|
{
|
||||||
name = "Basic Commands",
|
name = "Basic Commands",
|
||||||
@ -63,7 +67,7 @@ public Action:Command_Kick(client, args)
|
|||||||
|
|
||||||
GetClientName(clients[0], name, sizeof(name));
|
GetClientName(clients[0], name, sizeof(name));
|
||||||
|
|
||||||
decl String:reason[256]
|
decl String:reason[256];
|
||||||
if (args < 2)
|
if (args < 2)
|
||||||
{
|
{
|
||||||
/* Safely null terminate */
|
/* Safely null terminate */
|
||||||
|
@ -332,4 +332,4 @@ native KvSetEscapeSequences(Handle:kv, bool:useEscapes);
|
|||||||
* @return Number of non-root nodes in the jump stack.
|
* @return Number of non-root nodes in the jump stack.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvNodesInStack(Handle:kv);
|
native KvNodesInStack(Handle:kv);
|
||||||
|
@ -39,14 +39,16 @@ struct Plugin
|
|||||||
#include <timers>
|
#include <timers>
|
||||||
#include <admin>
|
#include <admin>
|
||||||
#include <dbi>
|
#include <dbi>
|
||||||
|
#include <lang>
|
||||||
#include <sorting>
|
#include <sorting>
|
||||||
|
#include <textparse>
|
||||||
#include <clients>
|
#include <clients>
|
||||||
#include <console>
|
#include <console>
|
||||||
#include <events>
|
#include <events>
|
||||||
#include <bitbuffer>
|
#include <bitbuffer>
|
||||||
#include <usermessages>
|
#include <usermessages>
|
||||||
|
#include <keyvalues>
|
||||||
#include <menus>
|
#include <menus>
|
||||||
#include <lang>
|
|
||||||
#include <halflife>
|
#include <halflife>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,4 +36,9 @@
|
|||||||
"#format" "{1:s}"
|
"#format" "{1:s}"
|
||||||
"en" "Kicked player '{1}'"
|
"en" "Kicked player '{1}'"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"Flooding the server"
|
||||||
|
{
|
||||||
|
"en" "You are flooding the server!"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user