SAMP ban system, why not?
#1

Hello,

Half of the top ranked server around samp does not gain benefits of samp's ban system. They create their own ban systems which kick a saved nickname/ip when it connects and i do the same thing. I was wondering why not using the main one? atleast it does drop connections and prevents then from joining. i.e banning the IP and reloading the bans once issued and then keep on checking the saved timestamp and comparing it with the current to drop the rows and unban the IPs?

Info: We deal with ~3000-4000 banned accounts. Which rounds approx around 100 bans/day. Our bans tend to expire in two weeks unless stated otherwise.
Reply
#2

Well,

A: A large samp.bans file can cause lag...
B: .ini files can be shit to work with
C: You'd need to use a filemanager or something to edit samp.bans in PAWN.
Reply
#3

If you have a large player-base and alot of bans, the default ban system is slow, as it needs to read the entire samp.bans file, remove the unbanned ip and rewrite the entire file again.

The default ban system is also a permanent ban system, as it doesn't hold timing information.

Custom made ban systems have alot more benefits.
If your own custom made ban-system also has an IP-check in it, why would you need the default samp ban-system on top of that?
You would have 2 different systems checking the same thing (the IP).
Seems like a waste of resources.



My own system for example allows a player to connect, the script checks his IP and searches the database if there is ANY banned account which holds the player's IP.
If one is found, the player is kicked.

This prevents banned players to create a new account (if you would only have account-bans).

If the first check is passed (no banned account found with the player's IP), the account itself is checked as well.
The player might have changed his IP (many ISP's work with DHCP).
If the account is not banned as well, the player is allowed to enter his password and log in.
If the account is banned, the player is kicked.

In both systems (IP-check and account-check), the player is kicked out and he's also informed how long the ban remains in effect.

With such a system, it's not even needed to use the default ban-system from samp itself.
Reply
#4

Rcon bans are not user friendly. Not for the user getting banned and neither for the admins using it. It's extremely primitive. It just says "You are banned from this server". That's it. Custom systems give you the option to let the player know why and when he was banned. Rcon bans also only support classful rangebans which is quite annoying because ranges aren't assigned like that.

I personally use an extensive table of all the CIDR ranges in the world which gives me a lot more flexibility in enforcing bans. For example, a range from Sweden ranging from 5.150.233.0 to 5.150.255.255. Banning 5.150.233.* is not enough, banning 5.150.*.* is way too much. Ranges stored as integers, of course, for optimal speed.
Reply
#5

When someone says "slow" in programming terms, they don't mean it takes several seconds or more to unban/ban a player.
"Slow" means that there are faster alternatives and also "slow" indicates that it might take +50ms to do one simple thing.

This may not look server-breaking but it might introduce lag-spikes when used often.

Also, reading/writing files in general is slow as they are not threaded.
The script must wait for reading/writing to be completed.

If rewriting the samp.bans file takes 100ms, your script can't do anything else.
Processing callbacks, timers, even OnPlayerConnect callbacks all have to wait until file-processing has been completed.

Also, generally speaking, you're not banning 10 players every second or so to experience serious lag which hinders your players.
If a player is banned once every 5 minutes, and your ban-system takes 100ms to execute the ban (rewriting samp.bans file), this will not break your server.
Your players MAY occasionally feel a lag-spike that only lasts 100ms.
But that doesn't mean it can't be improved either.

Using a MySQL database for your ban-system can use threaded queries and won't hog your server that much.
It also is more flexible as Vince already said, that you can determine the ban-time and give a custom message explaining why the player was banned.
Reply
#6

I'm trying to figure out a ban system that would work on a database.
Is there anyway to script timed bans without needing a timer?
If not, how can I make it the most efficient and less consuming?
Reply
#7

Quote:
Originally Posted by HeLiOn_PrImE
View Post
I'm trying to figure out a ban system that would work on a database.
Is there anyway to script timed bans without needing a timer?
If not, how can I make it the most efficient and less consuming?
you only really need to check a ban when they join, then if its expired remove it. but to keep my database clean I ran a timer with a 6 hour interval
Reply
#8

There is no need for a timer. Not in your script, and not in the database itself.

When you use a database, you can simply save the unix timestamp as an integer value in the player's account.
When you want to ban a player for a week for example, you can calculate the amount of seconds for one week.
One week equals to 7 * 24 * 60 * 60 = 604800 seconds.

In your ban command, you can use "gettime()" to get the current unix timestamp.
Add 604800 to the value returned by gettime() and save that value in the database.

When a player tries to login, load the bantime you saved and compare it to the current timestamp.
If the stored value is still larger than the current time, kick the player again because his ban-time isn't over yet.
If the stored value is smaller than the current time, allow him to login as his ban-time has expired.

There even is no need to clear that value in the database.
If your code is always checking this bantime value, it won't matter if the value is cleared (set to 0) or kept at a value lower than the current time.
It also allows admins to check the database and see at a glance who was banned at least once (bantime > 0).
Reply
#9

If you intend to let staff set the ban time, here's a short snippet for quickly grabbing an English string and converting it to seconds. It's a rather crude and basic parser but it does a decent job. Interprets (value) (unit) such as "1 week", "3 days", "1 day", etc:

pawn Код:
GetDurationFromString(string[])
{
    new
        value,
        type[16];

    if(sscanf(string, "ds[16]", value, type))
        return -1;

    if(value <= 0)
        return -1;

    if(!strcmp(type, "day", true, 3)) // only check 3 chars, technically "days" works, so does "daytona"...
        return value * 86400;

    if(!strcmp(type, "week", true, 4))
        return value * 604800;

    if(!strcmp(type, "month", true, 5))
        return value * 2628000;

    return -1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)