Here is the function:
What it should do:
A) If pet's health is already 100, it does nothing (and does not use the item).
B) If the pet's health is not 100, but the item value would put health OVER 100 then it instead only adds the amount needed to make 100.
C) If the pet's health is not 100, and the item value would not go over 100, then it just normally adds the item value to increase the health.
What it's doing:
My pet's health is at 100. I test it. It tells me that it worked, added 2, and my pet's health is now 100. Then it actually turns my pet's health to 0.
Now that my pet's health is at 0, I try again, it tells me that it added 2 and the health is now 2. Pet health still at 0.
Please help? ;_;
PHP:
function items_health($item, $adopt){
$mysidia = Registry::get("mysidia");
$addHealth = $adopt->health + $item->value;
//Check if the adoptable's health is already at maximum.
if($adopt->health = 100){
$note = "Your pet is already fully healed! The {$item->itemname} was not used.";
}
//Not a maximum, but don't go overboard!
if($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 pet's health by {$item->value}! Their health is now at {$addHealth}.";
$delitem = $item->remove();
}
return $note;
}
What it should do:
A) If pet's health is already 100, it does nothing (and does not use the item).
B) If the pet's health is not 100, but the item value would put health OVER 100 then it instead only adds the amount needed to make 100.
C) If the pet's health is not 100, and the item value would not go over 100, then it just normally adds the item value to increase the health.
What it's doing:
My pet's health is at 100. I test it. It tells me that it worked, added 2, and my pet's health is now 100. Then it actually turns my pet's health to 0.
Now that my pet's health is at 0, I try again, it tells me that it added 2 and the health is now 2. Pet health still at 0.
Please help? ;_;
Last edited: