Expiry - 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: Expiry (
/showthread.php?tid=630668)
Expiry -
SpaceRP - 17.03.2017
How to create VIP info command, where will write expiry vip
Код:
Float:pVipTime,
Set vip time
new viptime = gettime() + (mounth * 2592000);
PlayerInfo[giveplayerid][pVipTime] = viptime;
Re: Expiry -
Toroi - 17.03.2017
Like this? Also what does the macro
mounth do? And where the value
2592000 came from?
Код:
new expiretime = PlayerInfo[playerid][pVipTime] - gettime();
EDIT:
Oh ok, so
2592000 means 30 days.
Then it'd be something like:
Код:
new expiretime = (PlayerInfo[playerid][pVipTime] - gettime()) / 86400;
86400 means a day in seconds, you're retrieving the days left here. Or that's what I think it does.
I never went to school.
Re: Expiry -
SpaceRP - 17.03.2017
Код:
(33534) : warning 213: tag mismatch
CMD:vip(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pVip] < 1) return SCM(playerid, COLOR_WHITE, "Error!");
new string[100], viptime = PlayerInfo[playerid][pVipTime] - gettime();
if(PlayerInfo[playerid][pVipTime] != 0) { format(string, sizeof(string), "{FFFFFF}Expiry: {00A7EE}%d", viptime); }
else { format(string, sizeof(string), "Perm"); }
new string1[91];
format(string1, sizeof(string1), "VIP: %s {FFFFFF}| %s", VIPRank(PlayerInfo[playerid][pVip]), string);
SCM(playerid, COLOR_WHITE, string1);
}
return 1;
}
Re: Expiry -
Toroi - 17.03.2017
Hmm, as it is a division it may have decimals and convert it to a float, let's make the inverse:
Код:
new expiretime = floatround((PlayerInfo[playerid][pVipTime] - gettime()) / 86400);
If you need explanation on what we just did:
https://sampwiki.blast.hk/wiki/Floatround
Additional:
Код:
new viptime = gettime() + (mounth * 2592000);
PlayerInfo[giveplayerid][pVipTime] = viptime;
That code will work for the first time the guy gets a VIP. However, if it's the second time and he has VIP time left, it'll get buggy as you're adding the unix time once again to this variable.
I suggest you to do a previous check before adding it:
Код:
if(PlayerInfo[giveplayerid][pVipTime] > 0) viptime = mounth * 2592000;
else viptime = gettime() + (mounth * 2592000);
That way you don't add the unix time twice.