seany123 Posted March 8, 2009 Share Posted March 8, 2009 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??? Quote Link to comment https://forums.phpfreaks.com/topic/148484-more-help-needed/ Share on other sites More sharing options...
wildteen88 Posted March 8, 2009 Share Posted March 8, 2009 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); } Quote Link to comment https://forums.phpfreaks.com/topic/148484-more-help-needed/#findComment-779693 Share on other sites More sharing options...
Silverado_NL Posted March 8, 2009 Share Posted March 8, 2009 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); } } Quote Link to comment https://forums.phpfreaks.com/topic/148484-more-help-needed/#findComment-779702 Share on other sites More sharing options...
seany123 Posted March 8, 2009 Author Share Posted March 8, 2009 yeah the exp does go up in a pattern to a certain extent... like say from level 1 - level 20 the increase per level will be the same, then at level 21 the increase will be larger.... for 20 levels. im eventually planning for 500-1,000 levels. Quote Link to comment https://forums.phpfreaks.com/topic/148484-more-help-needed/#findComment-779757 Share on other sites More sharing options...
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.