Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Have you purchased a mod and lost your copy? Just file a support ticket through your "My Mods" page.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: Some help with code  (Read 87 times)

mystical

  • Basic Member
  • *
  • Reputation Power: 66
  • mystical has no influence.
  • Offline Offline
  • Posts: 15
    • View Profile
Some help with code
« on: September 10, 2011, 07:40:06 AM »
I am having trouble figuring this out. The code below is for a place to eat and drink. My problem is that when you purchase an item if you already have say max brave which is 5 it will give you too much brave. What I want to do is have it so if you already have max brave it gives you a message saying that you already have max brave or max energy which is 12. Can anyone point me in the right direction? I am really dumb when it comes to coding. Thanks.

Code: [Select]
<?php

include(DIRNAME(__FILE__) . "/globals.php");



if(
$ir['jail'] or $ir['hospital']) 
echo(
"This page cannot be accessed while in jail or visiting the Medicine Man.");


if(
$ir['grub'] > 2)
   {
      echo 
'<h1>Come Back Tomorrow Cowboy</h1>';
      exit(
$h->endpage());
   }
if (!
$_GET['spend'])
{
   echo 
'
   
 <img src="images/chuckwagon.png"><br>
   <b><i>Welcome To The Chuckwagon</i></b><br>
 
   <b><i>Want Some Grub? Step right up and get yourself some from Cookie!</i></b><br>
   <b>Meals</b>
 
   <table border="1">
      <tr>
         <th>Grub</th>
         <th>Cost</th>
         <th>Buy</th>
      </tr>
      <tr>
         <td>Eggs and Bacon</td>
         <td>$250</td>
         <td><a href="chuckwagon.php?spend=1">Buy</a></td>
      </tr>
      <tr>
         <td>Beans</td>
         <td>$400</td>
         <td><a href="chuckwagon.php?spend=2">Buy</a></td>
      </tr>
      <tr>
         <td>Rabbit Stew</td>
         <td>$700</td>
         <td><a href="chuckwagon.php?spend=3">Buy</a></td>
      </tr>
      <tr>
         <td>Fried Chicken</td>
         <td>$1000</td>
         <td><a href="chuckwagon.php?spend=4">Buy</a></td>
      </tr>
      <tr>
         <td>Steak and Taters</td>
         <td>$1500</td>
         <td><a href="chuckwagon.php?spend=5">Buy</a></td>
      </tr>
   <table>
    
 <br>
 
   <b>Liquid Refreshments</b>
 
   <table border="1">
      <tr>
         <th>Drink</th>
         <th>Cost</th>
         <th>Buy</th>
      </tr>
      <tr>
         <td>Water</td>
         <td>$250</td>
         <td><a href="chuckwagon.php?spend=6">Buy</a></td>
      </tr>
      <tr>
         <td>Milk</td>
         <td>$400</td>
         <td><a href="chuckwagon.php?spend=7">Buy</a></td>
      </tr>
      <tr>
         <td>coffee</td>
         <td>$700</td>
         <td><a href="chuckwagon.php?spend=8">Buy</a></td>
      </tr>
      <tr>
         <td>12 Beers</td>
         <td>$1000</td>
         <td><a href="chuckwagon.php?spend=9">Buy</a></td>
      </tr>
      <tr>
         <td>Bottle of Whiskey</td>
         <td>$1500</td>
         <td><a href="chuckwagon.php?spend=10">Buy</a></td>
      </tr>
   </table>'
;
}
else if(
$_GET['spend'] == 1)
{
   if(
$ir['money'] < 249)
   {
      echo 
'You don\'t have enough money to buy Eggs and Bacon, you need $250!';
   }
   else
   {
      
$sql sprintf("UPDATE users SET money=money-250, maxenergy=energy+2, grub=grub+1 WHERE userid=%s"$userid);
      
mysql_query($sql);
      echo 
'You bought Eggs and Bacon for $250! I had to chase that pig a mile and a half!
 </br>
      <a href="chuckwagon.php">Back to the Chuckwagon</a>
'
;
   }
}
else if(
$_GET['spend'] == 2)
{
   if(
$ir['money'] <399)
   {
      echo 
'You don\'t have enough money to buy the Beans, you need $400!';
   }
   else
   {
      
$sql sprintf("UPDATE users SET money=money-400, energy=energy+25, grub=grub+1 WHERE userid=%s"$userid);
 
      
mysql_query($sql);
      echo 
'You bought Beans for $400! Make sure you sleep with your tent flap open!
</br>
      <a href="chuckwagon.php">Back to the Chuckwagon</a>
'
;
   }
}
else if(
$_GET['spend'] == 3)
{
   if(
$ir['money'] <699)
   {
      echo 
'You don\'t have enough money to buy the Rabbit Stew, you need $700!';
   }
   else
   {
      
$sql sprintf("UPDATE users SET money=money-700, energy=energy+50, grub=grub+1 WHERE userid=%s"$userid);
 
      
mysql_query($sql);
      echo 
'You bought Rabbit Stew for $700! This will warm you right up!
 </br> 
      <a href="chuckwagon.php">Back to the Chuckwagon</a>
'
;
   }
}
 
else if(
$_GET['spend'] == 4)
{
   if(
$ir['money'] < 999)
   {
      echo 
'You don\'t have enough money to buy the Fried Chicken, you need $1000!';
   }
   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> 
      <a href="chuckwagon.php">Back to the Chuckwagon</a>
'
;
   }
}
else if(
$_GET['spend'] == 5)
{
   if(
$ir['money'] < 1499)
   {
      echo 
'You don\'t have enough money to buy the Steak and Potatoes, you need $1500!';
   }
   else
   {
      
$sql sprintf("UPDATE users SET money=money-250, energy=energy+100, grub=grub+1 WHERE userid=%s"$userid);
 
      
mysql_query($sql);
      echo 
'You bought Steak and Taters for $1500! That will fill ya up!
 </br> 
      <a href="chuckwagon.php">Back to the Chuckwagon</a>
'
;
   }
}
else if(
$_GET['spend'] == 6)
{
   if(
$ir['money'] < 249)
   {
      echo 
'You don\'t have enough money to buy Water, you need $250!';
   }
   else
   {
      
$sql sprintf("UPDATE users SET money=money-250, brave=brave+15, grub=grub+1 WHERE userid=%s"$userid);
 
      
mysql_query($sql);
      echo 
'You bought Water for $250! Good choice if ur ridin in the desert...
 </br> 
      <a href="chuckwagon.php">Back to the Chuckwagon</a>
'
;
   }
}
else if(
$_GET['spend'] == 7)
{
   if(
$ir['money'] <399)
   {
      echo 
'You don\'t have enough money to buy the Milk, you need $400!';
   }
   else
   {
      
$sql sprintf("UPDATE users SET money=money-400, brave=brave+25, grub=grub+1 WHERE userid=%s"$userid);
 
      
mysql_query($sql);
      echo 
'You bought a gallon of Milk for $400! I thought you were a man?
 </br> 
      <a href="chuckwagon.php">Back to the Chuckwagon</a>
'
;
   }
}
else if(
$_GET['spend'] == 8)
{
   if(
$ir['money'] <699)
   {
      echo 
'You don\'t have enough money to buy coffee, you need $700!';
   }
   else
   {
      
$sql sprintf("UPDATE users SET money=money-700, brave=brave+50, grub=grub+1 WHERE userid=%s"$userid);
      
mysql_query($sql);
      echo 
'You bought coffee for $700! That stuff will wake you up in the mornin!
 </br> 
      <a href="chuckwagon.php">Back to the Chuckwagon</a>
'
;
   }
}
 
else if(
$_GET['spend'] == 9)
{
   if(
$ir['money'] < 999)
   {
      echo 
'You don\'t have enough money to buy the Beer, you need $1000!';
   }
   else
   {
      
$sql sprintf("UPDATE users SET money=money-1000, brave=brave+75, grub=grub+1 WHERE userid=%s"$userid);
      
mysql_query($sql);
      echo 
'You bought twelve bottles of Beer for $1000! Happy drinkin!
 </br> 
      <a href="chuckwagon.php">Back to the Chuckwagon</a>
'
;
   }
}
else if(
$_GET['spend'] == 10)
{
   if(
$ir['money'] < 1499)
   {
      echo 
'You don\'t have enough money to buy a bottle of Whiskey, you need $1500!';
   }
   else
   {
      
$sql sprintf("UPDATE users SET money=money-250, brave=brave+100, grub=grub+1 WHERE userid=%s"$userid);
      
mysql_query($sql);
      echo 
'You bought a bottle Whiskey for $1500! Go easy on that stuff!
 </br> 
      <a href="chuckwagon.php">Back to the Chuckwagon</a>
'
;
   }
}
$h->endpage();
?>
« Last Edit: September 10, 2011, 07:48:23 AM by mystical »
Logged
 


This forum is now closed and has moved to a new location! Click here to find out why.