Jump to content
MakeWebGames

Question about a mod


Mystical

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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