Page 2 of 2

Re: Time Progressive Increase of number

Posted: Tue Sep 30, 2008 7:50 pm
by 8ennett
Took your advice with the status bar and just set two images to change depending on the current value of your stats and added it to a custom functions script so it can be relative to all pages,

Code: Select all

// Calculates the status bars in the header
function statbar($bar, $set){
    $setmax = $bar.'max';
    $barmax = $_SESSION['TheMob'][$setmax];
    $barper =  $_SESSION['TheMob'][$bar] / $barmax * 100;
    $barp = 100 - $barper;
    if ($barper < 25){ $image = 'red'; }
    else { $image = 'blank'; }
    if ($set == true){
    echo '<img src="images/statbar.PNG" width="'.($barper * 2).'" height="10"><img src="images/stat'.$image.'.PNG" width="'.($barp * 2).'" height="10">';
    }
    else {
    echo $_SESSION['TheMob'][$bar].'/'.$_SESSION['TheMob'][$setmax].'('.$barper.'%)';
    }
}
I included the else in there so I can include the written percentage on other pages and scripts instead of a visual without writing a similar function. All I need to do to call the images now is

Code: Select all

<?php statbar('hp', true); ?>
Just need to figure out the best way of increasing other users stats now. A cron job might be the most efficient way, users that are inactive obviously will have their health at max anyway, if it only takes about 30 minutes to refill at most then only users that have been online within the past 30 mins will need their health refilling assuming they have lost any (which will be 25% of onliners AT BEST). Otherwise it would just include a series of constant database queries on top of what is already going on.