ShadyCoco Posted September 2, 2011 Posted September 2, 2011 Hey.. I've been trying to work out how to make an EXP function for my little project. I'm honestly lost.. the only way I can get anything to work is with an if statment like so: <?php if($_USER['exp'] >= 100) { echo' You are level one.'; } elseif ($_USER['exp'] >= 500) { echo' You are level two'; } ?> They must be a much better way to do this I just don't know how. Any help at all, even other function that might help me would be great! Thanks Quote
Diesl Posted September 2, 2011 Posted September 2, 2011 It depends how you want to structure your EXP system, but one of the common ways is to base how much experience is needed on the users level. For instance; $expneeded = ($_USER['level']*10)+300; if($_USER['exp'] >= $expneeded) { $_USER['level']++; echo "You are now level ".$_USER['level']."; } With this, you are setting a base amount of experience needed to level (300) and then every level higher they go, they must obtain more experience. In my example, if your player is level 10, they must obtain 400 experience points to level up. You can modify this however you want to meet your needs. I hope this gives you a better idea. Quote
ShadyCoco Posted September 2, 2011 Author Posted September 2, 2011 Many many many thanks! Maybe I should of looked at math functions a little more :/ Again thanks! 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.