Jump to content
MakeWebGames

Recommended Posts

Posted

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

Posted

@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

Posted

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");

}

}

Posted

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

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...