25.06.2017, 18:47
Your code is a bit messy. It would be better to make a seperate function for that but when I script my ban system what I do is when a player is banned, I put his name, reason, admin who banned etc... and unban date (UNIX Timestamp).
Then when a player connects
I execute
if the rows affected is equal to 0 then that player is not banned
if it's 1 (Anything more than that and you have a bug somewhere)
I check the current timestamp to the unban date, if current stamp is less than the unban stamp then that player is still banned if it's not then he is no longed banned and I run this
It's more flexible I guess since you can save a lot more data than just banned or not.
Then when a player connects
I execute
Код:
SELECT * FROM bans WHERE username = '%s'
if it's 1 (Anything more than that and you have a bug somewhere)
I check the current timestamp to the unban date, if current stamp is less than the unban stamp then that player is still banned if it's not then he is no longed banned and I run this
Код:
DELETE FROM bans WHERE username = '%s