VIP status that last 30 days -
ax1 - 18.08.2016
I've made a VIP system, now I want to make VIP status last 30 days. How do I do that?
Re: VIP status that last 30 days -
Gammix - 18.08.2016
Save the date when you made him/her VIP:
pawn Код:
new variable = getdate();
// So you have saved this variable and loaded when player connected.
When player connects:
pawn Код:
public OnPlayerConnect(playerid)
{
if ((getdate() - variable) > 30)
{
// VIP expired
}
}
Re: VIP status that last 30 days -
ax1 - 18.08.2016
Quote:
Originally Posted by Gammix
Save the date when you made him/her VIP:
pawn Код:
new variable = getdate();
// So you have saved this variable and loaded when player connected.
When player connects:
pawn Код:
public OnPlayerConnect(playerid) { if ((getdate() - variable) > 30) { // VIP expired } }
|
What if I buy Vip at the last day of the year?
Re: VIP status that last 30 days -
Gammix - 18.08.2016
Quote:
Originally Posted by ax1
What if I buy Vip at the last day of the year?
|
It is actually that simple. For more accuracy, you can also use
gettime if you want exact date and time lapse.
Re: VIP status that last 30 days -
ax1 - 18.08.2016
What if I buy Vip at the last day of the year?
Re: VIP status that last 30 days -
Gammix - 18.08.2016
Well this is the best way:
Using:
http://forum.sa-mp.com/showpost.php?...50&postcount=3
Save date in 3 vars
pawn Код:
new day, month, year;
getdate(year, month, day);
To check:
pawn Код:
new todayyear, todaymonth, todayday;
getdate(todayyear, todaymonth, todayday);
if ((rdn(todayyear, todaymonth, todayday) - rdn(year, month, day)) > 30)
{
// Expired
}
Its still easy!
Re: VIP status that last 30 days -
SKAzini - 18.08.2016
Use the timestamp returned from
gettime() (as Gammix mentioned), which will work if they get VIP 1 day before a new year:
For when someone becomes VIP, store the timestamp in your database:
pawn Код:
new Hour, Minute, Second, Timestamp;
Timestamp = gettime(Hour, Minute, Second);
Users[playerid][VIPTime] = Timestamp;
And when they log in:
pawn Код:
new Hour, Minute, Second, Timestamp;
Timestamp = gettime(Hour, Minute, Second);
if (Timestamp - Users[playerid][VIPTime] >= 60 * 60 * 24 * 30) {
// remove VIP, since 30 days have passed
}
Re: VIP status that last 30 days -
Stuntff - 18.08.2016
My version:
check:
Код:
new current_time = gettime();
if(Users[playerid][pVIP] != -1)
{
if(Users[playerid][pVIP] <= current_time)
{
//expired
}
else
{
new days = floatround(((Users[playerid][pVIP] - current_time) / 86400), floatround_floor);
new string[55+3];
format(string,sizeof(string),"{FF8900}VIP status is lost after {FFFFFF}%d{FF8900} days",days);
SendClientMessage(playerid,-1,string);
}
}
buy:
Код:
Users[playerid][pVIP] = (gettime() + (30*86400));