SA-MP Forums Archive
[Tutorial] y_flooding - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] y_flooding (/showthread.php?tid=570902)



y_flooding - Misiur - 14.04.2015

This has been part of YSI for many years, but I don't remember ever documenting it.

There is just one function:

Code:
SetMaxConnections(max, action);
Both the parameters are optional, calling it with no parameters:

Code:
SetMaxConnections();
Removes all limits, and lets as many people as they like connect from the same IP.

The first parameter limits the number of connections from one IP:

Code:
SetMaxConnections(2);
That will let just two people (clients) connect at once on one IP.

The second parameter tells the system what to do if any extra clients connect from that IP. The default is "BLOCK" - any further connections will be refused. There are several other options:
The last one calls a callback, AND provides an iterator to list all the players on that IP:

Code:
public OnFloodLimitExcceded(ip[16], count)
{
    foreach (new i : FloodingPlayer)
    {
        SendClientMessage(i, 0xFF0000AA, "There are too many of you on this IP!");
        Kick(i);
    }
}