Premium days left?
Premium days left?
Is there any way to determine how many days of Premium membership a player has left?
- KyleMassacre
- Posts: 573
- Joined: Wed Nov 27, 2013 12:42 pm
Re: Premium days left?
Sure. You can use the TimeSpan or TimeLeft function (I forgot what it's called) or you can do something like:
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
Re: Premium days left?
I tried something like that but, it shows the wrong value if you look at someone else's profile. Any way to only show it on your own profile?
This how I modified the player_info.php file that's part of the Premium module
This how I modified the player_info.php file that's part of the Premium module
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");
Re: Premium days left?
ok, I think I got it. This code should (works on my server) display the Yes or No to being Premium Member and if its the players own profile it will display the days left.
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");
Re: Premium days left?
I wonder if something like your routine needs to go into the Premium Routine lib? With your permission of course.
Greg
Greg
Running a game is like riding a bike ... well it should be!
New Worlds Engine / FunMayhem.com
Helping you get your game concept up and running. Now.
New Worlds Engine / FunMayhem.com
Helping you get your game concept up and running. Now.
Re: Premium days left?
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
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
Running a game is like riding a bike ... well it should be!
New Worlds Engine / FunMayhem.com
Helping you get your game concept up and running. Now.
New Worlds Engine / FunMayhem.com
Helping you get your game concept up and running. Now.
Re: Premium days left?
Sent.
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