VIP System
#1

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.
Reply
#2

Using date and time functions from MySQL: https://dev.mysql.com/doc/refman/5.5...ction_date-add
pawn Код:
DATE_ADD(NOW(), INTERVAL 30 DAY)
in INSERT query. For automatic expiration, I advise you: https://sampforum.blast.hk/showthread.php?tid=546630
Reply
#3

<REMOVED>
Reply
#4

Will anyone help me?
Reply
#5

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
Using date and time functions from MySQL: https://dev.mysql.com/doc/refman/5.5...ction_date-add
pawn Код:
DATE_ADD(NOW(), INTERVAL 30 DAY)
in INSERT query. For automatic expiration, I advise you: https://sampforum.blast.hk/showthread.php?tid=546630
He just did.
Reply
#6

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();
Reply
#7

Quote:
Originally Posted by scripter112
Посмотреть сообщение
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();
To be Simple

Код:
PlayerInfo[id][pVipTime] = gettime() + 86400 * 30;
Reply
#8

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.
Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
Using date and time functions from MySQL: https://dev.mysql.com/doc/refman/5.5...ction_date-add
pawn Код:
DATE_ADD(NOW(), INTERVAL 30 DAY)
in INSERT query. For automatic expiration, I advise you: https://sampforum.blast.hk/showthread.php?tid=546630
Reply
#9

Код:
new VIPTEMP;  // Top of you script


// -- Under public OnGameModeInit() or FilerscriptInit()

VIPTEMP = 0;

//-- Use this in your code 

VIPTEMP = gettime() + 86400 * 30;
Now you can use VIPTEMP to UPDATE your database.
Reply
#10

Quote:
Originally Posted by KamilPolska
Посмотреть сообщение
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.
It really depends on your structure in the database. When player is set as vip for 30 days, set it in a new table:
pawn Код:
"INSERT INTO vip (userid, expire_at) VALUES (%d, DATE_ADD(NOW(), INTERVAL 30 DAY))"
or update the main table if this is where you save the vip information:
pawn Код:
"UPDATE users SET vip_expiration = DATE_ADD(NOW(), INTERVAL 30 DAY) WHERE userid=%d"
// vip_expiration default value is 0
The above are examples to understand.

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;
or
pawn Код:
CREATE EVENT vip_expire \
ON SCHEDULE EVERY 10 MINUTE \
STARTS NOW() \
DO \
DELETE FROM vip WHERE NOW() >= expire_at;
Again, these are examples. I do not know your tables.

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)