Mystical Posted December 9, 2011 Share Posted December 9, 2011 I found a mod on here a while back that I think was made by Illusions that was a food mod. Buy food or drink and raise your brave or energy. Below is a snipet of the code. else if($ir['energy'] == $ir['maxenergy']) { echo "You already have full energy."; } else { $sql = sprintf("UPDATE users SET money=money-1000, energy=energy+75, grub=grub+1 WHERE userid=%s", $userid); mysql_query($sql); echo 'You bought a Fried Chicken for $1000! I got all the feathers off it that I could! </br></br> <a href="chuckwagon.php">Back to the Chuckwagon</a> My question and before some wise acre says what a newbie question my reply will be I am a freekin newbie..... The question..... Say my max energy is 12/12... When I buy the fried chicken and my energy is say 10 it raises my max energy way past 12. How do you get it so it does not change to a number past my max energy? Quote Link to comment Share on other sites More sharing options...
Uridium Posted December 9, 2011 Share Posted December 9, 2011 (edited) $sql = sprintf("UPDATE users SET money=money-1000, energy=energy+75, grub=grub+1 WHERE userid=%s AND energy < max_energy", $userid); by the way i didnt make this mod... Edited December 9, 2011 by illusions Quote Link to comment Share on other sites More sharing options...
Maniak Posted December 10, 2011 Share Posted December 10, 2011 I don't think that's what he's after, Illusions.. What you need is: (I have taken the sprintf() out as well, as I don't code that way) elseif($ir['energy'] == $ir['maxenergy']) { echo "You already have full energy."; } else { if(($ir['maxenergy']-$ir['energy']) < 75) { $sql = 'UPDATE `users` SET `money`=money-1000, `energy`='.$ir['maxenergy'].', `grub`=grub+1 WHERE (`userid`='.$userid.')'; } else { $sql = 'UPDATE `users` SET `money`=money-1000, `energy`=energy+75, `grub`=grub+1 WHERE (`userid`='.$userid.')'; } mysql_query($sql); echo 'You bought a Fried Chicken for $1000! I got all the feathers off it that I could! </br></br> <a href="chuckwagon.php">Back to the Chuckwagon</a> I'm unsure if it'll work as I haven't coded in a long time, if it does someone may be able to make it more efficient; but that is to the best of my knowledge without looking at code for about a year. Quote Link to comment Share on other sites More sharing options...
Dave Posted December 10, 2011 Share Posted December 10, 2011 This was one of my incredibly old mods ha. It's pretty usless so I'd suggest not using it because I imagine it has a load of security holes. Quote Link to comment Share on other sites More sharing options...
Mystical Posted December 21, 2011 Author Share Posted December 21, 2011 Thanks to everyone for helping me figure this out and I will take Dave's advise and dump the mod. Thanks again. Quote Link to comment 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.