Jump to content
MakeWebGames

Levels


RedZone

Recommended Posts

I got a question this is VERY annoying. My game has bunnys on it like level 2000 players and when like level 5's beat the level 2000 to gain EXP/Levels every time they click on something they go up 1 level till they catch up to the amount of exp gained. Any ideas how to fix this? I wanna be able to show the right level the first time.

Link to comment
Share on other sites

Re: Levels

Happens in a lot of games. Player keeps their stats low but plays the game for a long time to become high lvl bunny not much you can do about that.

The problem you have is that $ir is controlling the update which as you mention doesnt update instantly and waits for the user to click click click

You should be able to remedy this in global_func.php find

 

function check_level()
{
global $db;
global $ir,$c,$userid;
$ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*($ir['level']+1)*2.2);
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']+=2;
$ir['maxbrave']+=2;
$ir['hp']+=50;
$ir['maxhp']+=50;
$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+2,maxenergy=maxenergy+2,maxbrave=maxbrave+2,
hp=hp+50,maxhp=maxhp+50 where userid=$userid");
}
}

 

add into it

$update_ir="true";

and before the db query

if ($update_ir==true)

so like this ....

 

if ($update_ir=="true") {
$db->query("UPDATE users SET level=level+1,exp=$expu,energy=energy+2,brave=brave+2,maxenergy=maxenergy+2,maxbrave=maxbrave+2,
hp=hp+50,maxhp=maxhp+50 where userid=$userid");
}

 

it should work ...i use a different leveling code so thats not tested on the original code.

Link to comment
Share on other sites

Re: Levels

 

I got a question this is VERY annoying. My game has bunnys on it like level 2000 players and when like level 5's beat the level 2000 to gain EXP/Levels every time they click on something they go up 1 level till they catch up to the amount of exp gained. Any ideas how to fix this? I wanna be able to show the right level the first time.

Go into your global file as they stated below your first post and you can just add in a "while" statement. This will make a player jump to the correct level on the very next click no matter how many levels they need to catch up to their EXP gain.

Link to comment
Share on other sites

Re: Levels

 

Happens in a lot of games. Player keeps their stats low but plays the game for a long time to become high lvl bunny not much you can do about that.

The problem you have is that $ir is controlling the update which as you mention doesnt update instantly and waits for the user to click click click

You should be able to remedy this in global_func.php find

 

function check_level()
{
global $db;
global $ir,$c,$userid;
$ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*($ir['level']+1)*2.2);
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']+=2;
$ir['maxbrave']+=2;
$ir['hp']+=50;
$ir['maxhp']+=50;
$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+2,maxenergy=maxenergy+2,maxbrave=maxbrave+2,
hp=hp+50,maxhp=maxhp+50 where userid=$userid");
}
}

 

add into it

$update_ir="true";

and before the db query

if ($update_ir==true)

so like this ....

 

if ($update_ir=="true") {
$db->query("UPDATE users SET level=level+1,exp=$expu,energy=energy+2,brave=brave+2,maxenergy=maxenergy+2,maxbrave=maxbrave+2,
hp=hp+50,maxhp=maxhp+50 where userid=$userid");
}

 

it should work ...i use a different leveling code so thats not tested on the original code.

 

All this is doing is the exact same thing it was doing... click, click, click, click..... it still has a SET level=level+1 so if 5 levels is jumped, it still takes the clicks to remedy it

Link to comment
Share on other sites

  • 4 weeks later...

Re: Levels

OK I know there is a better way but this works absolutely and without fail, no more click click click... Pay close attention to my exp needed calculation is changed from the original, just swap that out for yours.

find this

 

if($ir['exp'] >= $ir['exp_needed'])
{
$expu=$ir['exp']-$ir['exp_needed'];
$ir['level']+=1;
$ir['exp']=$expu;
$ir['energy']+=1;
$ir['brave']+=1;
$ir['maxenergy']+=1;
$ir['maxbrave']+=1;
$ir['hp']+=50;
$ir['maxhp']+=50;
$ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*2.2);
$db->query("UPDATE users SET level=level+1,exp=$expu,energy=energy+1,brave=brave+1,maxenergy=maxenergy+1,energy=maxenergy,maxbrave=maxbrave+1,
hp=hp+50,maxhp=maxhp+50,hp=maxhp where userid=$userid");
event_add($ir['userid'],"You just Gained a Level!");
}

 

Underneath it past this, notice the string sequence, this allows for 1 more level for each one added but change the strings in sequence to match up, otherwise it won't work, now some of you that has a better way feel free to post it, but for now this solves the problem of the clicks.

 

$ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*2.2);
if($expu >= $ir['exp_needed'])
{
$expa=$expu-$ir['exp_needed'];
$ir['level']+=1;
$ir['exp']=$expa;
$ir['energy']+=1;
$ir['brave']+=1;
$ir['maxenergy']+=1;
$ir['maxbrave']+=1;
$ir['hp']+=50;
$ir['maxhp']+=50;
$ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*2.2);
$db->query("UPDATE users SET level=level+1,exp=$expa,energy=energy+1,brave=brave+1,maxenergy=maxenergy+1,energy=maxenergy,maxbrave=maxbrave+1,
hp=hp+50,maxhp=maxhp+50,hp=maxhp where userid=$userid");
event_add($ir['userid'],"You just Gained a Level!");
}

 

After adding that one it will jump 2 levels now per click if you have enough XP built up to do so...

 

Add the third underneath that and it jumps 3 levels per click:

 

$ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*2.2);
if($expa >= $ir['exp_needed'])
{
$expb=$expa-$ir['exp_needed'];
$ir['level']+=1;
$ir['exp']=$expb;
$ir['energy']+=1;
$ir['brave']+=1;
$ir['maxenergy']+=1;
$ir['maxbrave']+=1;
$ir['hp']+=50;
$ir['maxhp']+=50;
$ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*2.2);
$db->query("UPDATE users SET level=level+1,exp=$expb,energy=energy+1,brave=brave+1,maxenergy=maxenergy+1,energy=maxenergy,maxbrave=maxbrave+1,
hp=hp+50,maxhp=maxhp+50,hp=maxhp where userid=$userid");
event_add($ir['userid'],"You just Gained a Level!");
}

 

Some of you view this as simple etc, it works, plain and simple.

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