04.01.2013, 11:21
Why are you making it yourself so hard, if SQL includes all functions that you need,
I show you how I make temporary bans,
First you create a column in your ban table with is type; timestamp
Then you insert a ban like:
Now you banned this person for 3 days.
Then when the players connect and you check if he is banned, and when it expires you simply use thigs:
Then you put this timestamp in a variable (int)
Then you use
I show you how I make temporary bans,
First you create a column in your ban table with is type; timestamp
Then you insert a ban like:
Код:
INSERT INTO `bans`(`username`, `start_date`, `expire_date`) VALUES ('%s', NOW(), NOW()+INTERVAL 10 DAY)
Then when the players connect and you check if he is banned, and when it expires you simply use thigs:
Код:
SELECT *,UNIX_TIMESTAMP(expire_date) AS timestamp FROM `bans` WHERE `username` = '%s' AND `IP` = '%s' AND `banned` = 1
Then you use
pawn Код:
new timestamp;
// put your 'timestamp' from the sql results inside the timestamp variable.
if(timestamp < gettime())
{
// the player should get unbanned because it's expired
}
else
{
// players should get kicked because he is still banned.
}