SA-MP Forums Archive
VIP System - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: VIP System (/showthread.php?tid=654488)



VIP System - KamilPolska - 29.05.2018

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.


Re: VIP System - Calisthenics - 29.05.2018

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


Re: VIP System - KamilPolska - 30.05.2018

<REMOVED>


Re: VIP System - KamilPolska - 30.05.2018

Will anyone help me?


Re: VIP System - GTLS - 31.05.2018

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.


Re: VIP System - scripter112 - 31.05.2018

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


Re: VIP System - UFF - 31.05.2018

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;



Re: VIP System - KamilPolska - 31.05.2018

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



Re: VIP System - UFF - 31.05.2018

Код:
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.


Re: VIP System - Calisthenics - 31.05.2018

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.