View Single Post
  #4  
Old 11-20-2016, 11:13 AM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 89,869
Dinocanid is on a distinguished road
Default

I think I fixed the problem. Try this:
PHP Code:
 function items_health($item$adopt){
  
$mysidia Registry::get("mysidia");
  
$health $mysidia->db->select("owned_adoptables", array("health"), "aid ='{$adopt->aid}'")->fetchObject();
  
$addHealth $adopt->health $item->value;
      
//Check if the adoptable's health is already at maximum.    
  
if($adopt->health >= 100){
    
$note "Your gryphon is already fully healed! The {$item->itemname} was not used.";
  }
  
//Not at maximum, but don't go overboard!
  
elseif($addHealth 100){
    
$mysidia->db->update("owned_adoptables", array("health" => 100), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
    
$note "The {$item->itemname} fully healed your gryphon!";
    
$delitem $item->remove();
  }
  
//Not at maximum, won't go overboard. Proceed.
  
else{
    
$mysidia->db->update("owned_adoptables", array("health" => $addHealth), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
    
$note "The {$item->itemname} raised your gryphon's health by {$item->value}! Their health is now at {$addHealth}.";
    
$delitem $item->remove();
  }
  return 
$note;

This part:
PHP Code:
$health $mysidia->db->select("owned_adoptables", array("health"), "aid ='{$adopt->aid}'")->fetchObject(); 
Probably isn't needed, it's just there from my debugging.
Looking back on this code, I can't really see what's different about it, but it apparently works on my end now? Let me know if it doesn't.
__________________

Last edited by Dinocanid; 11-20-2016 at 11:44 AM.
Reply With Quote