Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Addons and Modifications > Mys v1.3.x Mods

Reply
 
Thread Tools Display Modes
  #1  
Old 06-01-2017, 05:13 AM
Fox Fox is offline
Member
 
Join Date: Oct 2016
Location: Australia
Posts: 34
Gender: Female
Credits: 1,287
Fox is on a distinguished road
Default Second Currency with unique adopt shop Mod

So I see a lot of people asking for a second currency add-on. Well, here's what I did and it seems to be working for me along with a unique adopt shop for it.
If you find any issues please let me know.


Go to MyPHPAdmin

You'll be editing the adopts_settings one.

Open up the SQL query and enter in this.

PHP Code:
INSERT INTO `adopts_settings`(`name`, `value`) VALUES ('premiumcurrency''Your Currency Name'
You can change premiumcurrency to whatever suits you, but please note you'll need to change any future uses of it to what you want it to be.

Next you'll edit the adopts_users.
Go to Structure then add a new column.
I simply checked the money one structure and copied it with the name 'premiumcurrency'. (I'll add a pic when I'm home later)


Now we need to go to your file manager and make some changes.

I wanted to be able to manually add currency through the ACP, so we'll start there.
Go to your adminCP files, and find user.php.

Find this:
PHP Code:
$mysidia->db->update("users", array("email" => $mysidia->input->post("email")), "uid='{$mysidia->input->get("uid")}'");
            
$mysidia->db->update("users", array("money" => $mysidia->input->post("money")), "uid='{$mysidia->input->get("uid")}'"); 
and add beneath it:
PHP Code:
$mysidia->db->update("users", array("premiumcurrency" => $mysidia->input->post("premiumcurrency")), "uid='{$mysidia->input->get("uid")}'"); 
Continues to next post (won't let me post it all at once *sigh*)

Last edited by Fox; 06-01-2017 at 06:57 AM.
Reply With Quote
  #2  
Old 06-01-2017, 05:14 AM
Fox Fox is offline
Member
 
Join Date: Oct 2016
Location: Australia
Posts: 34
Gender: Female
Credits: 1,287
Fox is on a distinguished road
Default

Now we'll go back and find the settings.php

Find:
PHP Code:
public function globals(){
        
$mysidia Registry::get("mysidia");
        if(
$mysidia->input->post("submit")){
            
$settings = array('theme''sitename''browsertitle''cost',  'slogan''admincontact'
                              
'systemuser''systememail''startmoney'); 
And replace with:
PHP Code:
public function globals(){
        
$mysidia Registry::get("mysidia");
        if(
$mysidia->input->post("submit")){
            
$settings = array('theme''sitename''browsertitle''cost',  'slogan''admincontact'
                              
'systemuser''systememail''startmoney''premiumcost'); 
I simply added my premium cost on the end.

Now go back and into the Admincp View files. Find settingsview.php
Find:
PHP Code:
$document->setTitle($this->lang->basic_title);
        
$document->addLangvar($this->lang->basic);
        
$globalsForm = new FormBuilder("globalsform""globals""post");
        
$globalsForm->buildComment("Default Theme:   "FALSE)->buildTextField("theme"$mysidia->settings->theme)
                    ->
buildComment("Site Name:   "FALSE)->buildTextField("sitename"$mysidia->settings->sitename)
                    ->
buildComment("Site Title:   "FALSE)->buildTextField("browsertitle"$mysidia->settings->browsertitle)
                    ->
buildComment("Currency Name:     "FALSE)->buildTextField("cost"$mysidia->settings->cost)
                    ->
buildComment("Start Money:    "FALSE)->buildTextField("startmoney"$mysidia->settings->startmoney)
                    ->
buildComment("Site Slogan:    "FALSE)->buildTextField("slogan"$mysidia->settings->slogan)
                    ->
buildComment("Admin Email:   "FALSE)->buildTextField("admincontact"$mysidia->settings->admincontact)
                    ->
buildComment("System User:   "FALSE)->buildTextField("systemuser"$mysidia->settings->systemuser)
                       ->
buildComment("System Email:   "FALSE)->buildTextField("systememail"$mysidia->settings->systememail
And add in where suits you (I just added beneath the systememail):
PHP Code:
->buildComment("Premium Currency Name:   "FALSE)->buildTextField("premiumcost"$mysidia->settings->premiumcost
Now let's edit the userview.php
Find:
PHP Code:
$userForm->buildCheckBox(" Delete This User. <strong>This cannot be undone!</strong>""delete""yes")
                     ->
buildComment("Assign New Password: "FALSE)->buildPasswordField("password""pass1"""TRUE)
                     ->
buildComment("Passwords may contain letters and numbers only. Leave the box blank to keep the current password.")
                     ->
buildCheckBox(" Email the user the new password (Only takes effect if setting a new password) ""emailpwchange""yes")
                     ->
buildComment("Change Email Address: "FALSE)->buildTextField("email"$user->getemail())
                     ->
buildComment("Currency: "FALSE)->buildTextField("money"$user->money)
                     ->
buildCheckBox(" Ban this user's rights to click adoptables""canlevel""no")
                     ->
buildCheckBox(" Ban this user's rights to post profile comments""canvm""no")
                     ->
buildCheckBox(" Ban this user's rights to make trade offers""cantrade""no")
                     ->
buildCheckBox(" Ban this user's rights to send friend requests""canfriend""no")
                     ->
buildCheckBox(" Ban this user's rights to breed adoptables""canbreed""no")
                     ->
buildCheckBox(" Ban this user's rights to abandon adoptables""canpound""no")
                     ->
buildCheckBox(" Ban this user's rights to visit Shops""canshop""no"); 
And replace with:
PHP Code:
$userForm->buildCheckBox(" Delete This User. <strong>This cannot be undone!</strong>""delete""yes")
                     ->
buildComment("Assign New Password: "FALSE)->buildPasswordField("password""pass1"""TRUE)
                     ->
buildComment("Passwords may contain letters and numbers only. Leave the box blank to keep the current password.")
                     ->
buildCheckBox(" Email the user the new password (Only takes effect if setting a new password) ""emailpwchange""yes")
                     ->
buildComment("Change Email Address: "FALSE)->buildTextField("email"$user->getemail())
                     ->
buildComment("Currency: "FALSE)->buildTextField("money"$user->money)
->
buildComment("Premium Currency: "FALSE)->buildTextField("premiumcurrency"$user->premiumcurrency)
                     ->
buildCheckBox(" Ban this user's rights to click adoptables""canlevel""no")
                     ->
buildCheckBox(" Ban this user's rights to post profile comments""canvm""no")
                     ->
buildCheckBox(" Ban this user's rights to make trade offers""cantrade""no")
                     ->
buildCheckBox(" Ban this user's rights to send friend requests""canfriend""no")
                     ->
buildCheckBox(" Ban this user's rights to breed adoptables""canbreed""no")
                     ->
buildCheckBox(" Ban this user's rights to abandon adoptables""canpound""no")
                     ->
buildCheckBox(" Ban this user's rights to visit Shops""canshop""no"); 
Again, I just added the premium currency in.

We're all done here, now to make changes to our classes.
Find class_sidebar.php

Find this:
PHP Code:
protected function setMoneyBar(){
        
$mysidia Registry::get("mysidia");
        
$this->moneyBar = new Paragraph;
        
$this->moneyBar->add(new Comment("You have {$mysidia->user->money} {$mysidia->settings->cost}."));
        
        
$donate = new Link("donate");
        
$donate->setText("Donate Money to Friends");
        
$this->moneyBar->add($donate);
        
$this->setDivision($this->moneyBar);        
    } 
Replace with:
PHP Code:
protected function setMoneyBar(){
        
$mysidia Registry::get("mysidia");
        
$this->moneyBar = new Paragraph;
        
$this->moneyBar->add(new Comment("You have {$mysidia->user->money} {$mysidia->settings->cost}.<br>You have {$mysidia->user->premiumcurrency} {$mysidia->settings->premiumcost}."));
        
        
$donate = new Link("donate");
        
$donate->setText("Donate Money to Friends");
        
$this->moneyBar->add($donate);
        
$this->setDivision($this->moneyBar);        
    } 
That's as far as I've gone, I don't think I've missed anything, but I'll add to this when I get home and can create a shop for it.
Hope you find this useful!
Reply With Quote
  #3  
Old 06-01-2017, 06:38 AM
Fox Fox is offline
Member
 
Join Date: Oct 2016
Location: Australia
Posts: 34
Gender: Female
Credits: 1,287
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
  #4  
Old 06-01-2017, 06:39 AM
Fox Fox is offline
Member
 
Join Date: Oct 2016
Location: Australia
Posts: 34
Gender: Female
Credits: 1,287
Fox is on a distinguished road
Default

Now onto the class_stockadopt.php

Find:
PHP Code:
class StockAdopt{
  
// The StockItem class, which defines items currently in Itemshop and thus is not owned by any users
  
  
public $id 0;
  public 
$type;
  public 
$class;
  public 
$description;
  public 
$eggimage;
  public 
$whenisavail;
  public 
$alternates;     
  public 
$altoutlevel;    
  public 
$altchance;     
  public 
$cost;
  public 
$owner
And again, add this beneath public cost:
PHP Code:
public $premiumcost 
Then find:
PHP Code:
public function getcost($salestax 0){
      
// Get the total cost of this stock item
      
$cost $this->cost*(1+$salestax/100);
      return 
$cost;
  } 
And add below:
PHP Code:
public function getpremiumcost{
      
// Get the total cost of this stock item
      
$premiumcost $this->premiumcost;
      return 
$premiumcost;
  } 
Now we'll jump into the AdminCP files. In there, find the adopt.php

Find this chunk:
PHP Code:
$mysidia->db->insert("adoptables", array("id" =>  NULL"type" => $mysidia->input->post("type"), "class" =>  $mysidia->input->post("class"), "description" =>  $mysidia->input->post("description"), "eggimage" => $eggimage,  "whenisavail" => $mysidia->input->post("cba"),
                                                     
"alternates" =>  $mysidia->input->post("alternates"), "altoutlevel" =>  $mysidia->input->post("altoutlevel"), "altchance" =>  $mysidia->input->post("altchance"), "shop" =>  $mysidia->input->post("shop"), "cost" =>  $mysidia->input->post("cost"), "genderratio" =>  $mysidia->input->post("genderratio"))); 
and replace with:
PHP Code:
$mysidia->db->insert("adoptables", array("id" =>  NULL"type" => $mysidia->input->post("type"), "class" =>  $mysidia->input->post("class"), "description" =>  $mysidia->input->post("description"), "eggimage" => $eggimage,  "whenisavail" => $mysidia->input->post("cba"),
                                                     
"alternates" =>  $mysidia->input->post("alternates"), "altoutlevel" =>  $mysidia->input->post("altoutlevel"), "altchance" =>  $mysidia->input->post("altchance"), "shop" =>  $mysidia->input->post("shop"), "cost" =>  $mysidia->input->post("cost"), "premiumcost" =>  $mysidia->input->post("premiumcost"), "genderratio" =>  $mysidia->input->post("genderratio"))); 
Then we'll jump into the view folder in the AdminCP file to adoptview.php

Find this:
PHP Code:
$shopSettings->add(new Comment("Price: "FALSE));
        
$shopSettings->add(new TextField("cost"010)); 
And add beneath it:
PHP Code:
$shopSettings->add(new Comment("Premium Price: "FALSE));
        
$shopSettings->add(new TextField("premiumcost"010)); 
Next post for the final step!
Reply With Quote
  #5  
Old 06-01-2017, 06:39 AM
Fox Fox is offline
Member
 
Join Date: Oct 2016
Location: Australia
Posts: 34
Gender: Female
Credits: 1,287
Fox is on a distinguished road
Default

Now, if you followed Abronsyth's adopt shop with conditions, you should have a unique 'shop'.php and 'shop'view.php.

Open the 'shop'.php (whatever you decided to name it)
Find this:
PHP Code:
$cost $mysidia->db->select("adoptables", array("cost"), "type='{$adopt->getType()}'")->fetchColumn();
            
$moneyleft $mysidia->user->money $cost;

            if(
$moneyleft >= 0){ 
                
$mysidia->user->changecash(-$cost); 
And replace with:
PHP Code:
$premiumcost $mysidia->db->select("adoptables", array("premiumcost"), "type='{$adopt->getType()}'")->fetchColumn();
            
$gemsleft $mysidia->user->premiumcurrency $premiumcost;

            if(
$premiumcurrencyleft >= 0){ 
                
$mysidia->user->changegems(-$premiumcost); 
Now for the last step, open up the 'shop'view.php

Find:
PHP Code:
$cost = new Comment("{$adopts[$i]->getCost()} Mythirian Gold");
            
$costCell = new TCell;
            
$costCell->add($cost);
            
$costCell->setAlign(new Align("right"));            

            
$row->add($idCell);
            
$row->add($imageCell);
            
$row->add($typeCell);
            
$row->add($costCell);
            
$adoptTable->add($row);
        } 
And replace with:
PHP Code:
$premiumcost = new Comment("{$adopts[$i]->getPremiumCost()} Mythirian Gems");
            
$premiumcostCell = new TCell;
            
$premiumcostCell->add($premiumcost);
            
$premiumcostCell->setAlign(new Align("right"));            

            
$row->add($idCell);
            
$row->add($imageCell);
            
$row->add($typeCell);
            
$row->add($premiumcostCell);
            
$adoptTable->add($row);
        } 

And there you have it! A second currency and adopts to buy with it. I'll try to implement an item one too eventually.
Reply With Quote
  #6  
Old 06-06-2017, 09:01 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is online now
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: Somerville
Posts: 4,388
Gender: Male
Credits: 128,665
Hall of Famer is on a distinguished road
Default

Oh it looks nice, glad you figured this out, many people want such a Mod so bad. A minor suggestion, make an rar/zip download that include all changed files, this will be useful for users with fresh installation.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #7  
Old 06-10-2017, 05:17 PM
KatFennec's Avatar
KatFennec KatFennec is offline
Member
 
Join Date: Apr 2017
Posts: 57
Gender: Female
Credits: 1,331
KatFennec is on a distinguished road
Default

Quote:
Originally Posted by Fox View Post

Find this:
PHP Code:
$mysidia->db->update("users", array("email" => $mysidia->input->post("email")), "uid='{$mysidia->input->get("uid")}'");
            
$mysidia->db->update("users", array("money" => $mysidia->input->post("money")), "uid='{$mysidia->input->get("uid")}'"); 
The indicated code snippet doesn't seem to exist in the vanilla adminCP/users.php
__________________
Reply With Quote
  #8  
Old 06-11-2017, 08:46 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 996
Gender: Male
Credits: 41,258
Abronsyth is on a distinguished road
Default

KatFennec, it is in there (just checked to verify), for me it's around line 52.

I haven't added it yet, but very nice mod!
Reply With Quote
  #9  
Old 07-18-2017, 01:23 PM
LUC1G07CH1's Avatar
LUC1G07CH1 LUC1G07CH1 is offline
I'm a Unicorn
 
Join Date: Mar 2016
Location: Too distant for telling, but it's HUEBR
Posts: 103
Gender: Female
Credits: 3,453
LUC1G07CH1 is on a distinguished road
Default

Tried and it actually works.
But how to add an starter quantidy?

Edit: and an item shop with this currency?


Another edit: I thought i did everything right...but well...i has wrong.
"Database error 1054 - Unknown column 'premiumcost' in 'field list'"
__________________

Luci has here!

Last edited by LUC1G07CH1; 07-19-2017 at 09:24 AM.
Reply With Quote
  #10  
Old 08-27-2017, 02:27 AM
Silver_Brick Silver_Brick is offline
Designer || Coder
 
Join Date: Oct 2016
Location: In Earth
Posts: 204
Gender: Male
Credits: 7,723
Silver_Brick is on a distinguished road
Default

cool mod i like it
__________________

Last edited by Silver_Brick; 08-27-2017 at 02:33 AM.
Reply With Quote
Reply

Thread Tools
Display Modes

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:50 AM.

Currently Active Users: 198 (1 members and 197 guests)
Threads: 3,951, Posts: 31,454, Members: 15,542
Welcome to our newest members, b0bby303.
BER





What's New?

What's Hot?

What's Popular?


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