Banning in MySQL - 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)
+--- Thread: Banning in MySQL (
/showthread.php?tid=541569)
Banning in MySQL -
Ghazal - 12.10.2014
Hi,
Can someone explain to me banning, unbanning, offline banning, temporatory banning? (banning contains ip ban for sure)
If possible, with MySQL.
Note: I am not asking you to script for me but to explain for me.
Re: Banning in MySQL -
AnnaSB - 13.10.2014
First of all you need a table
Your table must have at least 5 columns: [Name] [IP] [BanIP] [BanUntil] [Permanent].
Name: varchar(24),
IP: varchar(16),
BanIP: bit,
BanUntil: timestamp,
Permanent: bit.
Saving data for bans
You should save data in standard format to prevent corruptions:
Name
is the name of the player being banned using GetPlayerName(...)
IP
is the player's IP using GetPlayerIP(...)
BanIP
indicates if the IP is banned too, or not: 0 for no and 1 for yes.
BanUntil
is a timestamp using MYSQL: ADDDATE(UTC_TIMESTAMP, %d) where %d is the count of days that ban should remain until.
Permanent
indicated if the ban should ignore the BanUntil and deny player every time she requests.
Checking and loading ban data
You should just check bans on player connect:
You just need to check if (NAME EXISTS) or if (IP EXISTS and its BanIP EQUALS '1').
If your logical circuits returned TRUE, you should load ban data: BanUntil and Permanent.
Now if Permanent is 1, you should kick the player, if it's 0, next step. Now you should get current UTC time using MYSQL: UTC_TIMESTAMP and check if it's greater that BanUntil's given vaule or not, if it is, remove the ban row and allow the player in, otherwise, KICK!
Hope I helped ^^
Re: Banning in MySQL -
Fj0rtizFredde - 13.10.2014
There are a lot of tutorials and filterscripts that covers both MYSQL and ban systems. Just search around on the forums.
Here is an example tutorial to get you started.
Re: Banning in MySQL -
Ghazal - 13.10.2014
Quote:
Originally Posted by AnnaSB
First of all you need a table
Your table must have at least 5 columns: [Name] [IP] [BanIP] [BanUntil] [Permanent].
Name: varchar(24),
IP: varchar(16),
BanIP: bit,
BanUntil: timestamp,
Permanent: bit.
Saving data for bans
You should save data in standard format to prevent corruptions:
Name is the name of the player being banned using GetPlayerName(...)
IP is the player's IP using GetPlayerIP(...)
BanIP indicates if the IP is banned too, or not: 0 for no and 1 for yes.
BanUntil is a timestamp using MYSQL: ADDDATE(UTC_TIMESTAMP, %d) where %d is the count of days that ban should remain until.
Permanent indicated if the ban should ignore the BanUntil and deny player every time she requests.
Checking and loading ban data
You should just check bans on player connect:
You just need to check if (NAME EXISTS) or if (IP EXISTS and its BanIP EQUALS '1').
If your logical circuits returned TRUE, you should load ban data: BanUntil and Permanent.
Now if Permanent is 1, you should kick the player, if it's 0, next step. Now you should get current UTC time using MYSQL: UTC_TIMESTAMP and check if it's greater that BanUntil's given vaule or not, if it is, remove the ban row and allow the player in, otherwise, KICK!
Hope I helped ^^
|
Thanks mate!
A reputation will be given in few seconds.