Thread: Mys 1.3.4 Second Currency Mod
View Single Post
  #3  
Old 06-01-2017, 06:38 AM
Fox Fox is offline
Member
 
Join Date: Oct 2016
Location: Australia
Posts: 34
Gender: Female
Credits: 5,949
Fox is on a distinguished road
Default

Creating an Adopt Shop for this Currency!

Follow the steps in Abronsyth's adoptable shop with conditions - clickity click

Now, there are a heap of steps for this one, and it took me quite some tinkering to figure this out.

We'll start with find the class_member.php file in classes.

Find this:
PHP Code:
 public function getcash(){
      return 
$this->money;
  }
  
  public function 
changecash($amount){     
      
$mysidia Registry::get("mysidia");
      if(!
is_numeric($amount)) throw new Exception('Cannot change user money by a non-numeric value!');
      
      
$this->money += $amount;    
      if(
$this->money >= 0){ 
         
$mysidia->db->update("users", array("money" => $this->money), "username = '{$this->username}'");
         return 
TRUE;              
      }
      else throw new 
InvalidActionException("It seems that {$this->username} cannot afford this transaction.");
  } 
And add after it:
PHP Code:
public function getgems(){
      return 
$this->premiumcurrency;
  }
  
  public function 
changegems($amount){     
      
$mysidia Registry::get("mysidia");
      if(!
is_numeric($amount)) throw new Exception('Cannot change user gems by a non-numeric value!');
      
      
$this->premiumcurrency += $amount;    
      if(
$this->premiumcurrency >= 0){ 
         
$mysidia->db->update("users", array("premiumcurrency" => $this->premiumcurrency), "username = '{$this->username}'");
         return 
TRUE;              
      }
      else throw new 
InvalidActionException("It seems that {$this->username} cannot afford this transaction.");
  } 
I used 'gems' as that's what my premium currency is. Change to whatever you like, just don't use cash.

Now let's jump to class_adoptable.php

Find:
PHP Code:
class Adoptable extends Model{

   protected 
$id;
    protected 
$type;
    protected 
$class;
    protected 
$description;
    protected 
$eggimage;
    protected 
$whenisavail;
    protected 
$alternates;
    protected 
$altoutlevel;
    protected 
$altchance;
    protected 
$shop;
    protected 
$cost;  
    protected 
$genderratio;
    protected 
$conditions;
    protected 
$levels
And add beneath protected cost:
PHP Code:
protected $premiumcost
Then find:
PHP Code:
public function getCost(){
        return 
$this->cost;
    } 
and add this below it:
PHP Code:
public function getPremiumCost(){
        return 
$this->premiumcost;
    } 
Continue to next post.

Last edited by Fox; 06-01-2017 at 06:53 AM.
Reply With Quote