18.11.2013, 23:41
(
Последний раз редактировалось Emmet_; 20.11.2013 в 14:36.
)
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:
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:
Or use BanIP(ip); to ban the players instead.
Here are a list of types associated with this callback:
Instructions
To install it on your server, simply add:
At the top of the script (preferably under a_samp).
To adjust the TIME_INTERVAL then do this:
Or the maximum number of connections per IP address:
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
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;
}
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;
}
Here are a list of types associated with this callback:
Feature | Description |
FLOOD_TYPE_CONNECT | This type is used when a specified number of IP's connect under the time interval. |
FLOOD_TYPE_CHAT | This type is used when a specified number of chats are sent under the time interval. |
FLOOD_TYPE_COMMAND | This type is used when a specified number of commands are executed under the time interval |
To install it on your server, simply add:
pawn Код:
#include <OFD>
To adjust the TIME_INTERVAL then do this:
pawn Код:
#define TIME_INTERVAL (2000) // 2000 milliseconds = 2 seconds!
#include <OFD>
pawn Код:
#define MAX_IP_CONNECTIONS (5)
#include <OFD>
Downloads
Pastebin
Solidfiles