31.05.2018, 12:52
Quote:
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. |
pawn Код:
"INSERT INTO vip (userid, expire_at) VALUES (%d, DATE_ADD(NOW(), INTERVAL 30 DAY))"
pawn Код:
"UPDATE users SET vip_expiration = DATE_ADD(NOW(), INTERVAL 30 DAY) WHERE userid=%d"
// vip_expiration default value is 0
MySQL server can update/remove vips automatically if you set a scheduler as (run this query once):
pawn Код:
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;
pawn Код:
CREATE EVENT vip_expire \
ON SCHEDULE EVERY 10 MINUTE \
STARTS NOW() \
DO \
DELETE FROM vip WHERE NOW() >= expire_at;
This will run a timer internally in mysql server. If you want to do it from the script, you can retrieve the unix timestamp and assign it in an array as shown earlier. But you better use a timer instead of OnPlayerUpdate.