[Include] OnFloodDetected
#1

OnFloodDetected

Introduction
Since I like releasing includes that introduce new and useful callbacks, I came up with this small but useful include which detects all types of flooding (connection flooding, chat and command flooding too).

This include has been updated. Now it won't crash the server when a player with an invalid name joins (con, lpt1, com1, etc).

How it works
The connection flooding detection works by detecting the amount of connections from the same IP during a short interval of time. If the number of connections exceed MAX_IP_CONNECTIONS, the OnFloodDetected callback is called.

This does not include NPC connections. I've tested it on my VPS with a bot tool and it works.

Callback
There is one callback only:

pawn Код:
public OnFloodDetected(playerid, ip[], type)
{
    return 1;
}
playerid is the ID of the last player who connected.
ip[] is the IP address of the player.
type is the type of flooding method used.

To kick all of the players that have the same IP address as ip[] then do this:

pawn Код:
public OnFloodDetected(playerid, ip[], type)
{
    if (type == FLOOD_TYPE_CONNECT)
    {
        KickIP(ip);
    }
    return 1;
}
Or use BanIP(ip); to ban the players instead.

Here are a list of types associated with this callback:

FeatureDescription
FLOOD_TYPE_CONNECTThis type is used when a specified number of IP's connect under the time interval.
FLOOD_TYPE_CHATThis type is used when a specified number of chats are sent under the time interval.
FLOOD_TYPE_COMMANDThis type is used when a specified number of commands are executed under the time interval
Instructions
To install it on your server, simply add:

pawn Код:
#include <OFD>
At the top of the script (preferably under a_samp).

To adjust the TIME_INTERVAL then do this:

pawn Код:
#define TIME_INTERVAL (2000) // 2000 milliseconds = 2 seconds!
#include <OFD>
Or the maximum number of connections per IP address:

pawn Код:
#define MAX_IP_CONNECTIONS (5)
#include <OFD>
There is also FLOOD_CHAT_LIMIT and FLOOD_CMD_LIMIT - for limiting the amount of chats sent or commands executed under the time interval by a single player.

Downloads
Pastebin
Solidfiles
Reply


Messages In This Thread
OnFloodDetected - by Emmet_ - 18.11.2013, 23:41
Respuesta: OnFloodDetected - by Swedky - 19.11.2013, 00:14
Re: Respuesta: OnFloodDetected - by Emmet_ - 19.11.2013, 00:21
Re: OnFloodDetected - by EvanA - 19.11.2013, 00:24
Re: OnFloodDetected - by Sublime - 19.11.2013, 00:30
Re: OnFloodDetected - by Jardell - 19.11.2013, 00:33
Re: OnFloodDetected - by Pottus - 19.11.2013, 00:42
Re: OnFloodDetected - by 420Scripter - 19.11.2013, 00:47
Re: OnFloodDetected - by KingServerIRAN - 19.11.2013, 07:59
Re: OnFloodDetected - by Emmet_ - 19.11.2013, 10:57
Re: OnFloodDetected - by Emmet_ - 19.11.2013, 19:33
Re: OnFloodDetected - by smeti - 19.11.2013, 19:52
Re: OnFloodDetected - by Emmet_ - 19.11.2013, 20:54
Re: OnFloodDetected - by Biesmen - 20.11.2013, 08:35
Re: OnFloodDetected - by Emmet_ - 20.11.2013, 12:41
Re: OnFloodDetected - by Biesmen - 20.11.2013, 13:31
Re: OnFloodDetected - by Patrick - 20.11.2013, 14:11
Re: OnFloodDetected - by Emmet_ - 20.11.2013, 14:29
Re: OnFloodDetected - by CriticalRP - 20.11.2013, 19:22
Re: OnFloodDetected - by Emmet_ - 20.11.2013, 19:24
Re: OnFloodDetected - by PT - 21.11.2013, 18:23
Re: OnFloodDetected - by Emmet_ - 21.11.2013, 19:32

Forum Jump:


Users browsing this thread: 2 Guest(s)