Premium days left?
Posted: Thu Nov 12, 2015 7:49 pm
Is there any way to determine how many days of Premium membership a player has left?
Code: Select all
$premium = GetUserVariable(premium);//I think that's the user var. double check please
$now = time();
echo floor(($premium-$now)/86400); //Take the 2 time stamps and subtract them, then divide it by the number of seconds in a day. Floor just does a hardcore round down to the nearest whole number. i.e 1.9 = 1
Code: Select all
global $userId, $user;
if ($user == null)
$user = $userId;
$currentMembership = GetUserVariable(premiumMember, $user) + 0;
$nowtime = time();
$timeleftA = ($currentMembership - $nowtime) / 86400;
$timeleft = round($timeleftA, 2);
if (GetConfigValue("premiumMembershipPrice", "premium") + 0 == 0)
return;
if (IsPremiumMember($_GET["id"] + 0))
$profileStats["Premium Member"] = Translate("Yes ($timeleft days left)");
else
$profileStats["Premium Member"] = Translate("No");
Code: Select all
<?php
global $userId, $user;
if ($user == null)
$user = $userId;
$currentMembership = GetUserVariable(premiumMember, $user) + 0;
$nowtime = time();
$timeleftA = ($currentMembership - $nowtime) / 86400;
$timeleft = round($timeleftA, 2);
if (GetConfigValue("premiumMembershipPrice", "premium") + 0 == 0)
return;
if (IsPremiumMember($_GET["id"] + 0))
if ($_GET["id"] + 0 == $userId) // The user itself
{
$profileStats["Premium Member"] = Translate("Yes ($timeleft days left)");
}
else
{
$profileStats["Premium Member"] = Translate("Yes");
}
else
$profileStats["Premium Member"] = Translate("No");
gmoore wrote:Okay. Send me an email: admin@funmayhem.com.
Include the code, state that you are giving this code to us (either as a bug fix or as public domain) to incorporate into our codebase.
I will put it in, test it and push it to everyone.
(This will probably be our normal way to put changes into the core code we have)
Thanx!
Greg