Premium days left?

General Chat, Comments
Post Reply
User avatar
cbsarge
Posts: 195
Joined: Mon Sep 14, 2015 3:20 pm

Premium days left?

Post by cbsarge »

Is there any way to determine how many days of Premium membership a player has left?
User avatar
KyleMassacre
Posts: 573
Joined: Wed Nov 27, 2013 12:42 pm

Re: Premium days left?

Post by KyleMassacre »

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
 
User avatar
cbsarge
Posts: 195
Joined: Mon Sep 14, 2015 3:20 pm

Re: Premium days left?

Post by cbsarge »

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

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");
User avatar
cbsarge
Posts: 195
Joined: Mon Sep 14, 2015 3:20 pm

Re: Premium days left?

Post by cbsarge »

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");
 
User avatar
gmoore
Posts: 212
Joined: Wed Jun 04, 2014 5:40 pm

Re: Premium days left?

Post by gmoore »

I wonder if something like your routine needs to go into the Premium Routine lib? With your permission of course.

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.
User avatar
cbsarge
Posts: 195
Joined: Mon Sep 14, 2015 3:20 pm

Re: Premium days left?

Post by cbsarge »

If you're asking me then absolutely ok with me. :D
User avatar
gmoore
Posts: 212
Joined: Wed Jun 04, 2014 5:40 pm

Re: Premium days left?

Post by gmoore »

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
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.
User avatar
cbsarge
Posts: 195
Joined: Mon Sep 14, 2015 3:20 pm

Re: Premium days left?

Post by cbsarge »

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
Post Reply

Return to “General”