Jump to content
MakeWebGames

stats bar


peterisgb

Recommended Posts

i know this might seem dumb but on the playerbars in your codes it will be in erm... header.php (i've changed mine so its different) well anyway

you have the stats bar on the side panel which is this selected code below:

 

$exp_needed=(($ir['level']+1.5)*($ir['level']+1.5)*($ir['level']+1)*2.7);
$enperc=(int) ($ir['energy']/$ir['maxenergy']*100);
$wiperc=(int) ($ir['will']/$ir['maxwill']*100);
$experc=number_format(($ir['exp']/$exp_needed*100), 2);
$brperc=(int) ($ir['brave']/$ir['maxbrave']*100);
$hpperc=(int) ($ir['hp']/$ir['maxhp']*100);
$gymperc=number_format(($ir['gymxp']/$ir['gexp_needed']*100), 2);
$enopp=100-$enperc;
$wiopp=100-$wiperc;
$exopp=100-$experc;
$bropp=100-$brperc;
$hpopp=100-$hpperc;
$gymopp=100-$gymperc;
print "<center>
<a id='button1b' href='energyrefill.php'>
<b>Energy:</b> {$ir['energy']}/{$ir['maxenergy']} <small>[<font color='green'>Refill</font>]</small><br />
<img src=bargreen.gif width=$enperc height=12><img src=barred.gif width=$enopp height=12>
</a>
<a id='button1b' href=''>
<b>Will:</b> {$wiperc}%<br />
<img src=bluebar.gif width=$wiperc height=12><img src=barred.gif width=$wiopp height=12>
</a>
<a id='button1b' href='criminal.php' target='_parent'>
<b>Brave:</b> {$ir['brave']}/{$ir['maxbrave']}<br />
<img src=barpurple.gif width=$brperc height=12><img src=barred.gif width=$bropp height=12>
</a>
<a id='button1b' href=''>
<b>Health:</b> {$hpperc}%<br />
<img src=bargreen.gif width=$hpperc height=12><img src=barred.gif width=$hpopp height=12>
</a>
<a id='button1b' href=''>
<b>XP:</b> {$experc}%<br />
<img src=bluebar.gif width=$experc height=12><img src=barred.gif width=$exopp height=12>
</a>
<a id='button1b' href=''>
<b>Gym XP:</b> {$gymperc}%<br />
<img src=bluebar.gif width=$gymperc height=12><img src=barred.gif width=$gymopp height=12></a>
<br /><br />
</center>";
}
?>

 

So well my point is these bars only go a certain percent which is 100% but this limits tge size width it goes,

How do i make the stats bar longer than what is it.

Link to comment
Share on other sites

Simple:

Change the 100s in:

$enopp=100-$enperc;

$wiopp=100-$wiperc;

$exopp=100-$experc;

$bropp=100-$brperc;

$hpopp=100-$hpperc;

$gymopp=100-$gymperc;

To your desired width then change the 100s in:

$exp_needed=(($ir['level']+1.5)*($ir['level']+1.5)*($ir['level']+1)*2.7);

$enperc=(int) ($ir['energy']/$ir['maxenergy']*100);

$wiperc=(int) ($ir['will']/$ir['maxwill']*100);

$experc=number_format(($ir['exp']/$exp_needed*100), 2);

$brperc=(int) ($ir['brave']/$ir['maxbrave']*100);

$hpperc=(int) ($ir['hp']/$ir['maxhp']*100);

$gymperc=number_format(($ir['gymxp']/$ir['gexp_needed']*100), 2);

to the smae desired width understand?

That should work

Link to comment
Share on other sites

You should create a new bunch od DIV tags in the styling section and then use those to adjust your stat progress bars, below is a sample code similar to what i use (i hope this is what you mean btw)

I have included the mccode's variables so hopefully they will work for you or give you an idea of who i got them working, i'd suggest having a play around with the code to get it how you want, but overall if you change the "width" in the css under ".prog-empty-top" it should change the overall length but keep the health percentages normal for you.

Add this into your code where you want your stat bar to appear

<div class="hp">
     <table>
<tr>
<td rowspan='2'><img src='[b]INSERT ICON HERE[/b]'> </td><td> Health <span id="health_stats">{$ir['energy'}]/{$ir['maxenergy'}</span></td>
</tr>
<tr><td><div class="prog-empty-top" title="{$ir['energy'}]/{$ir['maxenergy'}"><div class="prog-bar-top" id="prog-bar-hp" style="width: {$ir['energy']/$ir['maxenergy']*100}%;" title="{$ir['energy'}]/{$ir['maxenergy'}"> </div></div></td>
</tr>
     </table>
</div>

 

Add this to your stylesheet or into the header styling

[CSS]

.hp { color:#FFFFFF; float: left; font-size:10px; line-height:16px; margin-bottom: 1px; margin-right: 10px; }

.prog-empty-top { background:#373737 none repeat scroll 0 0; font-size:1px; height:8px; padding:1px; width:120px;}

.prog-bar-top { background:transparent url( INSERT BACKGROUND IMAGE HERE) repeat-x scroll left top; height:8px; margin:0; padding:0; }

[/CSS]

here's a screenshot of what the above should look similar too (0bviously you will need to edit it to suit your game etc)

http://prntscr.com/5uumr

 

P.S - take note this works for me but it may not work for everyone and the coding may not be the clearest to understand but i hope it gives you an idea of somewhat how to go about on finding a solution for your conundrum.

Cheers Pricey:cool:

Edited by pricey
Link to comment
Share on other sites

Oh jeez forgot dont change the 100s in this group:

 

$exp_needed=(($ir['level']+1.5)*($ir['level']+1.5)*($ir['level']+1)*2.7);

$enperc=(int) ($ir['energy']/$ir['maxenergy']*100);

$wiperc=(int) ($ir['will']/$ir['maxwill']*100);

$experc=number_format(($ir['exp']/$exp_needed*100), 2);

$brperc=(int) ($ir['brave']/$ir['maxbrave']*100);

$hpperc=(int) ($ir['hp']/$ir['maxhp']*100);

$gymperc=number_format(($ir['gymxp']/$ir['gexp_needed']*100), 2);

Link to comment
Share on other sites

  • 2 weeks later...

well not for me, this is my whole page

 

<style type="text/css">
<!--
body {
font-family:arial;font-size:12px;color: red;
  scrollbar-base-color: #005B70;
  scrollbar-arrow-color: #F3960B;
  scrollbar-DarkShadow-Color: #000000;
}
a:visited,a:active,a:hover,a:link { color: white;text-decoration: none; }
table,tr,td { font-family:arial;font-size: 12px; }
img { border:none; }
textarea { font-family:arial;font-size:12px;color: black; }
a#button1a {
   display: block;
   width: 170px;
   height: 16px;
   background-image: url(menu.jpg);
   background-position: 0 0;
   margin: 0 auto;
}
a#button1a:hover {
   background-image: url(menu3.jpg);  
   background-position: 0 -37px;
}
a .alt { display: none; }

a#button1b {
   display: block;
   width: 170px;
   height: 30px;
   background-image: url(menu3.jpg);
   background-position: 0 0;
   margin: 0 auto;
}
a#button1b:hover {
   background-image: url(menu3.jpg);  
   background-position: 0 -37px;
}
a .alt { display: none; }
-->
</style>
<?php
session_start();
if (!isset ($_SESSION['userid']) ) {
   echo '<p>Not logged in.</p>';
   exit;
}
include "config.php";
global $_CONFIG,$set,$ir;
define("MONO_ON", 1);
require "class/class_db_{$_CONFIG['driver']}.php";
$db=new database;
$db->configure($_CONFIG['hostname'],
$_CONFIG['username'],
$_CONFIG['password'],
$_CONFIG['database'],
$_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;
$set=array();
$settq=$db->query("SELECT * FROM settings");
while($r=$db->fetch_row($settq))
{
$set[$r['conf_name']]=$r['conf_value'];
}
$userInfo = $db->query('SELECT `userid`, `level`, `energy`, `maxenergy`, `will`, `maxwill`, `brave`, `maxbrave`, `exp`, `hp`, `maxhp`, `gymxp`, `gexp_needed` FROM `users` WHERE (`userid` = '.$_SESSION['userid'].')');
if ($db->num_rows($userInfo) > 0) {
   $ir = $db->fetch_row($userInfo);
$exp_needed=(($ir['level']+1.5)*($ir['level']+1.5)*($ir['level']+1)*2.7);
$enperc=(int) ($ir['energy']/$ir['maxenergy']*100);
$wiperc=(int) ($ir['will']/$ir['maxwill']*100);
$experc=number_format(($ir['exp']/$exp_needed*100), 2);
$brperc=(int) ($ir['brave']/$ir['maxbrave']*100);
$hpperc=(int) ($ir['hp']/$ir['maxhp']*100);
$gymperc=number_format(($ir['gymxp']/$ir['gexp_needed']*100), 2);
$enopp=100-$enperc;
$wiopp=100-$wiperc;
$exopp=100-$experc;
$bropp=100-$brperc;
$hpopp=100-$hpperc;
$gymopp=100-$gymperc;
print "<center>

<a id='button1b' href='energyrefill.php'>
<b>Energy:</b> {$ir['energy']}/{$ir['maxenergy']} <small>[<font color='green'>Refill</font>]</small><br />
<img src=bargreen.gif width=$enperc height=12><img src=barred.gif width=$enopp height=12>
</a>

<a id='button1b' href=''>
<b>Will:</b> {$wiperc}%<br />
<img src=bluebar.gif width=$wiperc height=12><img src=barred.gif width=$wiopp height=12>
</a>

<a id='button1b' href='criminal.php' target='_parent'>
<b>Brave:</b> {$ir['brave']}/{$ir['maxbrave']}<br />
<img src=barpurple.gif width=$brperc height=12><img src=barred.gif width=$bropp height=12>
</a>

<a id='button1b' href=''>
<b>Health:</b> {$hpperc}%<br />
<img src=bargreen.gif width=$hpperc height=12><img src=barred.gif width=$hpopp height=12>
</a>

<a id='button1b' href=''>
<b>XP:</b> {$experc}%<br />
<img src=bluebar.gif width=$experc height=12><img src=barred.gif width=$exopp height=12>
</a>

<a id='button1b' href=''>
<b>Gym XP:</b> {$gymperc}%<br />
<img src=bluebar.gif width=$gymperc height=12><img src=barred.gif width=$gymopp height=12></a>
<br /><br />


</center>";
}
?>
Link to comment
Share on other sites

<?php
//$stat = stat like energy?
//$maxStat = stat like maxenergy?
if ($stat == 0) {
   $perc = 0;
} else if ($stat == $maxStat) {
   $perc = 100;
} else {
   $perc = floor(($stat/$maxStat)*100);
}
?>
<!--Inline styles for ease of demonstration-->
<div class="barEmpty" style="width:204px;">
   <div class="barFill" style="width:<?php echo $perc; ?>%;"></div>
</div>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...