View Single Post
  #4  
Old 07-09-2009, 11:47 PM
Seapyramid Seapyramid is offline
Premium Member
 
Join Date: Feb 2009
Posts: 373
Gender: Female
Credits: 16,063
Seapyramid
Default RE: Item & Health Integration

Add a health field to your owned_adoptables table.. make it not null & give it a start point.. Mystic Grove start is 20

on another page for items this was added

Code:
             /* ****************
               Healing Spell
               ***************** */
          } elseif ($do == "Healing") {
              // We are actually placing in or removing from Dorm...
              
              
              $article_title = "Healing Potion<br /><br />";
              $article_content = "<center><img src='" . $itemimage . "'></center><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; With war comes valor, but also injuries and even death! The Healing Potion can not bring the dead back to life but it can help to sooth the pain and heal the injuries of those wounded in the Goodly Battle. The Healing Potion will help you Companion to recover from it's wounds up to 5 days sooner then what would happen naturally with time. It is useable only once and then it will disappear.<br /><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Which companion would you like to use the " . $type . " Potion on?<br /><br />";
              
              $article_content = $article_content . "<div id='petdisplay' align='center'> <ul>";
              // Now we choose a Companion or Item to use it on...
              
              
              $query = "SELECT * FROM " . $prefix . "owned_adoptables WHERE owner='$loggedinname' AND health < '20' AND health != '0' AND currentlevel = '6' AND item != 'yes'";
              $result = mysql_query($query);
              $num = mysql_numrows($result);
              
              $i = 0;
              while ($i < $num) {
                  //The item's ID
                  $aid = @mysql_result($result, $i, "aid");
                  $name = @mysql_result($result, $i, "name");
                  $health = @mysql_result($result, $i, "health");
                  
                  
                  
                  // Get the image for the adopt...
                  $itemimage = getcurrentitemimage($id);
                  $image = getcurrentimage($aid);
                  
                  $go = $name . "<a href='useitem.php?act=Healing&id=" . $id . "&aid=" . $aid . "'><img src='" . $image . "' border=0></a><b>Health: " . $health . "/20 ";
                  //Loop out code
                  
                  
                  
                  $article_content = $article_content . "<li><h5><center>" . $go . " </center></h5></li>";
                  
                  
                  $i++;
              }
              $article_content = $article_content . "</ul></div><br /><div></div>";
which sent info to another page.. this code

Code:
      
      /* ****************
       Healing Potion
       ***************** */
      
      if ($isloggedin == "yes") {
          if ($act == "Healing") {
              if ($id == "" or !is_numeric($id)) {
                  $article_title = $err_idnoexist;
                  $article_content = $err_idnoexist_text;
              } else {
                  $query = "DELETE FROM `adopts_owned_items` WHERE `aid`='$id'";
                  $result = mysql_query($query);
                  // die(print_r($query));
                  
                  // We have what appears to be a valid adoptable ID, so we pull the adoptable's information from the database...
                  
                  $query = "SELECT * FROM " . $prefix . "owned_adoptables WHERE aid='$aid'";
                  $result = mysql_query($query);
                  $num = mysql_numrows($result);
                  
                  //Loop out code
                  $i = 0;
                  while ($i < 1) {
                      $aid = @mysql_result($result, $i, "aid");
                      $name = @mysql_result($result, $i, "name");
                      $owner = @mysql_result($result, $i, "owner");
                      $health = @mysql_result($result, $i, "health");
                      $i++;
                  }
                  
                  if ($health < "20") {
                      // Now we see if the adoptable is dead.  If it is, we do not heal...
                      
                      if ($health == "0") {
                          $article_title = "This Companion is DEAD!";
                          $article_content = "<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This Companion has died and is well beyound the abilities of this Healing Potion!";
                      } else {
                          // Add health points to the total health of this adoptable...
                          $newhealth = $health + 5;
                          
                          // Actually insert our health information into the database...
                          
                          $query = "UPDATE " . $prefix . "owned_adoptables SET health='" . $newhealth . "' WHERE aid='" . $aid . "'";
                          mysql_query($query);
                          
                          
                          // End the if statement of healing
                          $image = getcurrentimage($aid);
                          $itemimage = getcurrentitemimage($id);
                          
                          $article_title = "Healing Potion";
                          $article_content = "<br /><br /><center><img src=" . $image . "><br /><br />The Healing Potion has eased " . $name . "'s pain and brought it's health up to " . $newhealth . "/20 !</center>";
                      }
                  } else {
                      // Adoptable is invalid, show an error...
                      
                      $article_title = $err_idnoexist;
                      $article_content = $err_idnoexist_text;
                  }
              }
          }
      }
to make it finally work & that is just the basic healing.

Sea
Reply With Quote