SA-MP Forums Archive
[Tutorial] Fixing connect flooding with the IRC plugin - 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] Fixing connect flooding with the IRC plugin (/showthread.php?tid=552081)



Fixing connect flooding with the IRC plugin - renegade334 - 22.12.2014

Hi folks,

The IRC.tl servers have issued dozens of network bans recently due to misbehaving gamemodes flooding the network with half-open connections. This is due to scripters' poor handling of disconnection events with the IRC plugin.

If you use the IRC plugin and know that you have explicit disconnect/reconnect handling, it's advisable to check whether or not any of the following applies to you.
If you have been directed here because your host has been banned by an IRC network, then following the steps below should fix your issues.

1) IRC PLUGIN UPGRADE
Version 1.4.6 of the IRC plugin features a couple of tweaks and bugfixes for disconnect handling. If you are running an earlier version, you need to upgrade it, particularly if you use the IRC_Quit function in your gamemode.

Download links: https://sampforum.blast.hk/showthread.php?tid=98803

2) IRC_ONDISCONNECT HANDLING
If a bot's connection to the IRC server fails, the IRC plugin will automatically attempt to reconnect the bot. That means that the IRC_OnDisconnect callback should not be interpreted as the "bot is about to be destroyed" callback - the bot is only destroyed if it was disconnected by the IRC_Quit function, not if the connection failed unintentionally.

A lot of misbehaving bots have code similar to the following:
pawn Code:
public IRC_OnDisconnect(botID, ip[], port, reason[]) {
    // I presume that the bot has been destroyed, so let's create a new one!
    MyIRCBotConnectFunction();

    /* other stuff */
}
This is WRONG. Wrong, wrong, wrong. The existing IRC bot has NOT been destroyed, and will be automatically reconnected to the server. This code will duplicate the bot: the existing botID will automatically reconnect, and you've created a new bot as well.

If you have code that looks like this, there are two ways to fix it. Either: Happy scripting, and Merry Christmas!

- R