Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 11-19-2016, 12:31 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 113,088
Abronsyth is on a distinguished road
Default New Item Function Issues

Here is the function:
PHP Code:
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? ;_;
__________________
My Mods Site (1.3.4, 2020 Mods)

Last edited by Abronsyth; 11-19-2016 at 12:48 PM.
Reply With Quote
  #2  
Old 11-19-2016, 01:16 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 64,789
Dinocanid is on a distinguished road
Default

Just tested this and I can't seem to replicate it. Do you have anything that lowers the health of your pet elsewhere?
I did notice that the item was used even if the pet's health was at 100 though, so that can be prevented by changing:
PHP Code:
if($addHealth 100){ 
to:
PHP Code:
elseif($addHealth 100){ 
__________________
Reply With Quote
  #3  
Old 11-20-2016, 08:35 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 113,088
Abronsyth is on a distinguished road
Default

For some reason it seems to just keep resetting it to 0.

Here is the function currently:
PHP Code:
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 gryphon is already fully healed! The {$item->itemname} was not used.";
  }
  
//Not a 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;

The health is at 0, and when I use the potion it now tells me that my pet is already fully healed, and it doesn't use the item up, but the health is still 0.
__________________
My Mods Site (1.3.4, 2020 Mods)

Last edited by Abronsyth; 11-20-2016 at 08:41 AM.
Reply With Quote
  #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: 64,789
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
  #5  
Old 11-20-2016, 01:10 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 113,088
Abronsyth is on a distinguished road
Default

OK, seems to be working now. I need to test a few more things still, and then I'll know for sure.

EDIT: Yes, all three instances are working flawlessly!

Thank you! I really appreciate the help <3
__________________
My Mods Site (1.3.4, 2020 Mods)

Last edited by Abronsyth; 11-20-2016 at 01:22 PM.
Reply With Quote
  #6  
Old 11-20-2016, 01:43 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 64,789
Dinocanid is on a distinguished road
Default

No problem!
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 10:27 AM.

Currently Active Users: 6295 (0 members and 6295 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636