Jump to content

more help needed.


seany123

Recommended Posts

what im trying to make a game... and basically everytime a player levels up his maxexp (amount of exp till next level) goes up to make it harder each time to gain a level.

 

i actually do have like a written down a amount of exp for every level..

 

my current tactic to make this happen is to go to every query which updates the players level and add the code in...

 

except my problem is im going to have like 2000 lines just for this... for example...

 

 

if($player->level == 1){

update ($player->maxexp == 5000);

}

 

else if($player0>level == 2){

update ($player->maxexp == 12,000);

}

 

and so on,

 

can anybody suggest a better more efficient way of doing this???

Link to comment
https://forums.phpfreaks.com/topic/148484-more-help-needed/
Share on other sites

How many levels are there and does the maxexp go up in a pattern (fore example goes up 7000 per level)

 

You could do

if($player->level == 1)
{
   update ($player->maxexp = 5000);
}
else
{
    $nextMaxEP = 5000 + (7000 * $player->level);
    update ($player->maxexp = $nextMaxEP);
}

Link to comment
https://forums.phpfreaks.com/topic/148484-more-help-needed/#findComment-779693
Share on other sites

I doubt it will go up 7k each level, seeing first level only has 5k points. and most games u need like double the xp for each level u gain.

 

i think ur best bet it to put the "player level" and "MaxExp" value's into an array.

and when a player levels up, run through the array and execute the update player function with the assigned value's

 

$array = array(	"1"=>"5000"	,
	"2"=>"12000"	,
	"3"=>"23000"	);

foreach($array as $level => $max_exp){
if($player_level == $level){                            // $player_level has to have the player level as value ofcourse to work
	update ($player->maxexp = $max_exp);
}
}

Link to comment
https://forums.phpfreaks.com/topic/148484-more-help-needed/#findComment-779702
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.