Thread: Mys 1.3.4 Simple NPC Battle
View Single Post
  #30  
Old 12-16-2016, 03:20 PM
lotus's Avatar
lotus lotus is offline
Member
 
Join Date: Oct 2016
Posts: 7
Gender: Female
Credits: 1,043
lotus is on a distinguished road
Default

@Corsair
Try adding this to see if it'll help (make sure to define $traincost):
PHP Code:
if($mysidia->user->money $traincost) {
   
$document->add(new Comment(" You don't have enough money to train your companion!"));
  return;


Came up with a code to automatically change an adopt's stats emulating $mysidia->user->changecash(). This should be helpful updating the db with less code. Add it to /classes/class_ownedadoptable.php
PHP Code:
public function changestat($stat$gainstat){
    
$mysidia Registry::get("mysidia");
        if(!
is_numeric($gainstat)) throw new Exception('Cannot change crocuta stats by a non-numeric value!'); 
       
# Define $newstat...
       
if($stat == "sense"){
          
$newstat $this->sense;
          } elseif(
$stat == "strength"){
          
$newstat $this->strength;
          }
                 
      
$newstat += $gainstat;     
      
      
$profile $mysidia->user->getprofile();
         
$mysidia->db->update("owned_adoptables", array("{$stat}=> $newstat), "aid = '{$profile->getFavPetID()}'"); 
         return 
TRUE;               
      
      } 
To use:
PHP Code:
$randgain rand(1,20);
$favpet->changestat(strength$randgain); 

Last edited by lotus; 12-16-2016 at 03:24 PM.
Reply With Quote