Ban system with mysql
#1

Hello! How can i make /ban system with days, exemple: if today i have banned someone for 10 days, the next day ban will be 9 days and same with next days
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=549574
Reply
#3

Quote:
Originally Posted by ReD_HunTeR
Посмотреть сообщение
With days not hours.
Reply
#4

Use that tutorial but then accept the input as days rather than hours. You can then multiply the value they input by 24 and you'll have a ban system that bans by days.
Reply
#5

Create a column for expiration with datatype TIMESTAMP.

pawn Код:
// in command /ban
new targetid, days, reason[33];
if (sscanf(params, "rds[32]", targetid, days, reason)) ...

mysql_format(..., "INSERT INTO ... (..., expiration) VALUES (..., TIMESTAMPADD(DAYS, %d, NOW())", ..., days);
TIMESTAMPADD function adds N days to current date and time: https://dev.mysql.com/doc/refman/8.0...n_timestampadd

Few extra information you may need:
https://dev.mysql.com/doc/refman/8.0...unix-timestamp
https://dev.mysql.com/doc/refman/8.0..._from-unixtime
https://dev.mysql.com/doc/refman/8.0..._timestampdiff
Reply
#6

In your MySQL table, create a column with data type timestamp, and when you ban some player, calculate the days using the days seconds * days banned.
When a player that is banned joins, check if their ban expired or not, if its not then kick them with the reason and the unban date, if it expired then remove the ban from the table and let them join..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)