peterisgb Posted January 5, 2012 Posted January 5, 2012 hello, on the stats bars it show the exp as a 2 digit figure, aka 24% how would i go about changing this to a decimal display eg. 24.56% and pointes in the right direction would be good Quote
Ishraq Posted January 5, 2012 Posted January 5, 2012 // Format modified to allow 2 decimal places $experc=number_format(($ir['exp']/$ir['exp_needed']*100), 2); // End Quote
peterisgb Posted January 5, 2012 Author Posted January 5, 2012 Warning: Division by zero in /home/ividenco/public_html/playerbars.php on line 81 Quote
sniko Posted January 5, 2012 Posted January 5, 2012 @Biohazard, I don't believe there is a `exp_needed` field, thus causing the division by zero. I don't have a default header nor global_func to see what the variable is to hold the exp needed. So; Go to header Find the exp bar line Find the formula to work out how much is left (I.E 24%) Use what Biohazard posted Quote
peterisgb Posted January 5, 2012 Author Posted January 5, 2012 its in the global_func.php function check_level() { global $db; global $ir,$c,$userid; $ir['exp_needed']= (($ir['level']+1.5)*($ir['level']+1.5)*($ir['level']+1)*2.7); if($ir['exp'] >= $ir['exp_needed']) { $expu=$ir['exp']-$ir['exp_needed']; $ir['level']+=1; $ir['exp']=$expu; $ir['energy']+=2; $ir['brave']+=2; $ir['maxenergy']+=4; $ir['maxbrave']+=4; $ir['hp']+=50; $ir['maxhp']+=50; $ir['levelpoints']+=1; $ir['money']+=500000; $ir['crystals']+=100; $ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*($ir['level']+1)*2.2); $db->query("UPDATE users SET level=level+1,exp=$expu,energy=energy+2,brave=brave+4,maxenergy=maxenergy+2,maxbrave=maxbrave+4, hp=hp+50,maxhp=maxhp+50,money=money+500000,crystals=crystals+100,levelpoints=levelpoints+1 where userid=$userid"); } } Quote
peterisgb Posted January 5, 2012 Author Posted January 5, 2012 but i have done this now this is abit harder for me as i forgot to mention that the stats are not in header on my game, but in an iframe on its own but i did this $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); which now works thanks for the help Quote
Ishraq Posted January 5, 2012 Posted January 5, 2012 No problemo. We need to bring this forum back alive. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.