SA-MP Forums Archive
[Include] FloodControl.inc ─ Easily block flood bots - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] FloodControl.inc ─ Easily block flood bots (/showthread.php?tid=320649)

Pages: 1 2 3


FloodControl.inc ─ Easily block flood bots - RyDeR` - 24.02.2012

Introduction

I saw JernejL's topic about blocking flood bots and read this comment:
Quote:
Originally Posted by JernejL
Посмотреть сообщение
Anyways, i post snippets.. i'm hoping someone of you will turn this into a filterscript that reads a flood limit number off a cfg file and enables people to easily set up flood control.
So I decided to quickly create a simple include which makes it very easy to manage everything.

Functions

We have only one callback:
pawn Код:
forward OnPlayerFloodControl(playerid, iCount, iTimeSpan);
And two defines:
pawn Код:
#if !defined MAX_JOIN_LOGS
    #define MAX_JOIN_LOGS (50)
#endif
pawn Код:
#if !defined MAX_THRESHOLD
    #define MAX_THRESHOLD (8000) // The amount of time in which all joins are valid and counted
#endif
Your custom values will be applied once you set these values before including it.

Example

The following example will IP-Ban the player/bot that joined more than 2 times in a time span of less then 8 seconds:
pawn Код:
#include <a_samp>
#include <FloodControl>

public OnPlayerFloodControl(playerid, iCount, iTimeSpan) {
    if(iCount > 2 && iTimeSpan < 8000) {
        Ban(playerid);
    }
}

public OnPlayerConnect(playerid) {
    return 1;
}
You can customize it like however you want it.

Download

FloodControl.inc

Changelog



Respuesta: FloodControl.inc ─ Easily block flood bots - [Nikk] - 24.02.2012

Exelent ryder, this is great, great work.


Re: FloodControl.inc ─ Easily block flood bots - Niko_boy - 24.02.2012

LoL another flood control i just seen Jernejl's Flood control one :O
And press back button and seen urs lol
Nice


Re: FloodControl.inc ─ Easily block flood bots - Kaperstone - 24.02.2012

GJ and thank you


Re: FloodControl.inc ─ Easily block flood bots - Michael@Belgium - 24.02.2012

Nice release And do you mind if i use it in my cPanel ?


Re: FloodControl.inc ─ Easily block flood bots - RyDeR` - 24.02.2012

Thanks!

Quote:
Originally Posted by Niko_boy
Посмотреть сообщение
LoL another flood control i just seen Jernejl's Flood control one :O
And press back button and seen urs lol
Nice
Hmm, let me think... What about reading the first post?


Quote:
Originally Posted by Michael@Belgium
Посмотреть сообщение
Nice release And do you mind if i use it in my cPanel ?
Sure, you can use it like however you want it.


Re: FloodControl.inc ─ Easily block flood bots - Modrlicc - 25.02.2012

Just tested and it works brilliant, thanks.


Re: FloodControl.inc ─ Easily block flood bots - lordturhan - 26.02.2012

Wow thats so nice i will update my server because i was so annoyed with those bunch of bots!


Re: FloodControl.inc ─ Easily block flood bots - Lorenc_ - 26.02.2012

"rcon 0"

That would work as well.


Re: FloodControl.inc ─ Easily block flood bots - lordturhan - 26.02.2012

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
"rcon 0"

That would work as well.
What do you mean?


Re: FloodControl.inc ─ Easily block flood bots - wups - 26.02.2012

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
"rcon 0"

That would work as well.
That secures from Rcon flooders, not bot connects.

Anyway, RyDeR`, do you think 3 connects per 10 seconds is surely a bot? I mean, people could have a few pc's in their houses, and connect with them at ~the same time.


Re: FloodControl.inc ─ Easily block flood bots - RyDeR` - 26.02.2012

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
"rcon 0"

That would work as well.
No, you're confusing RCON flood with bots connecting to a server like normal players.

Quote:
Originally Posted by wups
Посмотреть сообщение
Anyway, RyDeR`, do you think 3 connects per 10 seconds is surely a bot? I mean, people could have a few pc's in their houses, and connect with them at ~the same time.
Sure, that's possible, but that's just an example. You could add a few more if blocks containing different criteria under the callback.


Re: FloodControl.inc ─ Easily block flood bots - wups - 26.02.2012

Okay, I checked out your hooking method, and it needs some adjustments.
For example, if I don't have OnPlayerConnect callback(which is a rare case), then funcidx will keep repeating every time(and we know, that the callback won't magically appear).
That's just a minor thing you should look up in future developments.

I'm using this include for sure. Thanks.


Re: FloodControl.inc ─ Easily block flood bots - Translator - 27.02.2012

Can you post the download of the .inc file not pastebin thanks.


Re: FloodControl.inc ─ Easily block flood bots - wups - 27.02.2012

Quote:
Originally Posted by Translator
Посмотреть сообщение
Can you post the download of the .inc file not pastebin thanks.
There is a download link.
http://pastebin.com/download.php?i=FxS1CyX5


Re: FloodControl.inc ─ Easily block flood bots - RyDeR` - 27.02.2012

Quote:
Originally Posted by wups
Посмотреть сообщение
Okay, I checked out your hooking method, and it needs some adjustments.
For example, if I don't have OnPlayerConnect callback(which is a rare case), then funcidx will keep repeating every time(and we know, that the callback won't magically appear).
That's just a minor thing you should look up in future developments.

I'm using this include for sure. Thanks.
Will check it out.


Re: FloodControl.inc ─ Easily block flood bots - RyDeR` - 28.06.2012

Important update! Please re-download and recompile your gamemode as soon as possible if you're using this and care about security. Check changelog for more information.

Quote:
Originally Posted by ******
Посмотреть сообщение
pawn Код:
if(iHasOPC == -1) {
        iHasOPC = funcidx("FC_OnPlayerConnect");
    }
    if(iHasOPC != -1) {
        return CallLocalFunction("FC_OnPlayerConnect", "i", playerid);
    }
That code will call "funcidx" every time "OnPlayerConnect" is called if there is no other callback, entirely negating the point of using that hook method.
I remember wups making me aware of this a while ago in the previous page, but for some reason I forgot to check it out.

Quote:
Originally Posted by ******
Посмотреть сообщение
There is also a bug in your period check code - you don't take the "g_eaJoinLog" overflow in to account when looking for the first connection from an IP. The first connection could actually be later in the array than the current one, but you always start checking from the start of the array; possibly giving a much higher time span than is actually involved.
Should be fixed now.

Quote:
Originally Posted by ******
Посмотреть сообщение
And your code is very hard to read given your re-use of poorly named variables. Why is "iTimeSpan" "szIP[2]" in the "OnPlayerConnect" code? How does that relate in any way?
Well, instead of recreating variables, I'm just re-using them, that's why it's a bit harder to read. Also szIP[2] contains the total time of the amount of joins, what's wrong with that?


Re: FloodControl.inc ─ Easily block flood bots - RyDeR` - 28.06.2012

Quote:
Originally Posted by ******
Посмотреть сообщение
I'm also not sure why you're using float maths in the first place...
Because I need the absolute value between the two timestamps and we have no native "abs" function for integers.


Re: FloodControl.inc ─ Easily block flood bots - RyDeR` - 28.06.2012

Quote:
Originally Posted by ******
Посмотреть сообщение
pawn Код:
abs(a)
{
    return (a < 0) ? (-a) : (a);
}
Well I know, I just didn't want to implement it. What's wrong floatabs and floatround anyway?


Re: FloodControl.inc ─ Easily block flood bots - RyDeR` - 28.06.2012

Agreed with the slowness, but in this case, it's not inaccurate at all!