...

View Full Version : Exp Bar (please help)



rebel-rpg
08-30-2009, 11:34 PM
//Calculate EXP %
global $experc;
global $expopp;
$expn = $userstats3[level] * 65;
$experc = $userstats3[exp] / 100 * $expn;
$experc = round($experc,0);
$exopp = 100 - $experc;


E X P : <?php echo $experc ?>%
<img src="greenbar.png" width="<?php echo $experc ?>" height="10"><img src="redbar.png" width="<?php echo $exopp ?>" height="10">


http://i31.tinypic.com/20frp5e.jpg

for some reason it wont stop at 100% and i cant seem to fix this problem.
i could really use the help as i am not the best coder :) thank you, Nate

Mwnciau
08-31-2009, 12:03 AM
You're code isn't very clear but to find percentage you divide by the total then multiply by 100 not divide by 100 then multiply by the total


$experc = $userstats3[exp] / $expn * 100;

Edit:

On second thoughts, that will just give a high percentage all the time, what you need to do is this (in pseudo-code):


(UsersXP - totalXPforPreviousLevel)/(totalXPforNextLevel - totalXPforPreviousLevel) * 100

rebel-rpg
08-31-2009, 12:28 AM
You're code isn't very clear but to find percentage you divide by the total then multiply by 100 not divide by 100 then multiply by the total


$experc = $userstats3[exp] / $expn * 100;

Edit:

On second thoughts, that will just give a high percentage all the time, what you need to do is this (in pseudo-code):


(UsersXP - totalXPforPreviousLevel)/(totalXPforNextLevel - totalXPforPreviousLevel) * 100


accually i used:


$experc = $userstats3[exp] / $expn * 100;

and that seemed to fix it. it only goes over by a lil bit. but once you battle again then it just goes back down.

example:
it will be at 95%, after you click battle again, it goes to 110%, then after you click battle one more time it will go back to 7%. so its working alright i guess, that and i dont know what this means..:

(UsersXP - totalXPforPreviousLevel)/(totalXPforNextLevel - totalXPforPreviousLevel) * 100

could i paste it were this is?


$experc = $userstats3[exp] / $expn * 100;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum