29.05.2018, 20:30
How to make a VIP system for days in MySQL BlueG. The player chooses vip for 30 days, he sets the player to vipa and saves himself in the database. This is to be in the dialogue to select the vip.
DATE_ADD(NOW(), INTERVAL 30 DAY)
Using date and time functions from MySQL: https://dev.mysql.com/doc/refman/5.5...ction_date-add
pawn Код:
|
You can use unix timestamp
example: PlayerInfo[id][pVipTime] = (gettime() + 60 * 60 * 24 * 30); and you can use OnPlayerUpdate to remove playe's vip when PlayerInfo[id][pVipTime] >= gettime(); |
PlayerInfo[id][pVipTime] = gettime() + 86400 * 30;
Using date and time functions from MySQL: https://dev.mysql.com/doc/refman/5.5...ction_date-add
pawn Код:
|
new VIPTEMP; // Top of you script // -- Under public OnGameModeInit() or FilerscriptInit() VIPTEMP = 0; //-- Use this in your code VIPTEMP = gettime() + 86400 * 30;
Will I have to use PlayerInfo[playerid][pVip] for rank and PlayerInfo[playerid][pVipTime] for vip time?
For automatic expiration I do not know how to do it. I checked this link and I do not understand it. |
"INSERT INTO vip (userid, expire_at) VALUES (%d, DATE_ADD(NOW(), INTERVAL 30 DAY))"
"UPDATE users SET vip_expiration = DATE_ADD(NOW(), INTERVAL 30 DAY) WHERE userid=%d"
// vip_expiration default value is 0
CREATE EVENT vip_expire \
ON SCHEDULE EVERY 10 MINUTE \
STARTS NOW() \
DO \
UPDATE users SET vip_expiration=0 WHERE vip_expiration<>0 AND NOW() >= vip_expiration;
CREATE EVENT vip_expire \
ON SCHEDULE EVERY 10 MINUTE \
STARTS NOW() \
DO \
DELETE FROM vip WHERE NOW() >= expire_at;