With the release of Mys v1.3.6, old mods/addons are no longer working with the new version. For this reason, I've decided to update my own mods/addons for compatibility of the latest release. The first one is this Gender ratio mod, which allows site admins to set unbalanced gender for new adoptables(and if you wish, some adoptables can be male-only or female-only). I've included a link to the Mysidia Resource Manager that you can download the zip file and upload everything there to your site via FTP. Make sure to overwrite existing files, and then enter the directory /install and execute the file /install/genderratio.php so that the column genderratio will be inserted successfully into the database(as well as a record inserted into table prefix_acp_hooks).
The download link in Mysidia Resource Manager can be accessed from this url below:
Incase you cannot use the default files I have provided for some reason, I am writing a simple guide for manual installation of this Mod. To begin with, go to PhpMyAdmin and insert the column `genderratio` into your table `prefix.adoptables`. Its type is INT, default value should be 50. You may also use the query tab to execute this following query manually(assuming default table prefix, changes adopts_ to whatever it is for you incase it is different):
Also insert a record into the table prefix_acp_hooks, this will allow the plugin to be enabled/disabled via ACP. You may execute this query from PhpMyAdmin:
After the SQL part is done, go to your script file /model/domainmodel/adoptables.php, locate the list of properties:
Add a new property $genderratio below the code:
Then find the following code(at line 128 for unmodified file, method Adoptables::getGender()):
replace by:
Now we need to add some code to the ACP. Go to /controller/admincp/adoptcontroller.php and find the line that inserts adoptables record to database(line 58 for unmodified code, inside method AdoptController::add()):
And replace the above chunk of code by the new code below, which allows field gender ratio to be saved to database:
Finally, we still need to modify the adoptable creation form in ACP to add a textfield for gender ratio. Simply go to /view/admincp/adoptview.php and locate these lines of code(starting at line 108 for unmodified code, inside method AdoptView::add()):
And add the following code above these lines(actually it actually does not matter if you mistakenly inserted these lines below instead, thats the beauty of OOP and GUI!):
So this marks the end of manual installation process, hopefully its not much more complicated than last time(just the query for acp_hooks is new addition, as I've decided that admins can enable/disable this mod in ACP)? I hope you enjoy the Mods I am making for the script, I've decided to work on a few more new plugins for the script in the next few days. Lemme know if you have any suggestions to make, please do lemme know.
The download link in Mysidia Resource Manager can be accessed from this url below:
Gender Ratio Mod v1.3.6
This mod allows site admins to set unique values to determine the likelihood of an adoptable being born as male or female, instead of the default(which is half-half). It even allows certain species to be male-only or female-only. To download...
forums.mysidiaadoptables.com
Incase you cannot use the default files I have provided for some reason, I am writing a simple guide for manual installation of this Mod. To begin with, go to PhpMyAdmin and insert the column `genderratio` into your table `prefix.adoptables`. Its type is INT, default value should be 50. You may also use the query tab to execute this following query manually(assuming default table prefix, changes adopts_ to whatever it is for you incase it is different):
SQL:
ALTER TABLE adopts_adoptables ADD genderratio INT DEFAULT 50 AFTER cost
Also insert a record into the table prefix_acp_hooks, this will allow the plugin to be enabled/disabled via ACP. You may execute this query from PhpMyAdmin:
SQL:
INSERT INTO adopts_acp_hooks (`linktext`, `linkurl`, `pluginname`, `pluginstatus`) VALUES ('Gender Ratio Mod v1.3.6', 'https://forums.mysidiaadoptables.com', 'gender_ratio', 1)
After the SQL part is done, go to your script file /model/domainmodel/adoptables.php, locate the list of properties:
PHP:
protected $id;
protected $type;
protected $class;
protected $description;
protected $eggimage;
protected $whenisavail;
protected $alternates;
protected $altoutlevel;
protected $altchance;
protected $shop;
protected $cost;
protected $conditions;
protected $levels;
Add a new property $genderratio below the code:
PHP:
protected $genderratio;
Then find the following code(at line 128 for unmodified file, method Adoptables::getGender()):
PHP:
public function getGender(){
$genders = ['f', 'm'];
return $genders[rand(0,1)];
}
replace by:
PHP:
public function getGenderRatio(){
return $this->genderratio;
}
public function getGender(){
$plugins = Registry::get("plugins");
if($plugins->isEnabled("gender_ratio")){
$genderNumber = rand(0, 99);
return ($genderNumber < $this->genderratio) ? "f" : "m";
}
else{
$genders = ["f", "m"];
return $genders[rand(0,1)];
}
}
Now we need to add some code to the ACP. Go to /controller/admincp/adoptcontroller.php and find the line that inserts adoptables record to database(line 58 for unmodified code, inside method AdoptController::add()):
PHP:
$mysidia->db->insert("adoptables", ["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" => (int)$mysidia->input->post("altoutlevel"), "shop" => (int)$mysidia->input->post("shop"), "cost" => (int)$mysidia->input->post("cost")]);
And replace the above chunk of code by the new code below, which allows field gender ratio to be saved to database:
PHP:
$mysidia->db->insert("adoptables", ["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" => (int)$mysidia->input->post("altoutlevel"), "shop" => (int)$mysidia->input->post("shop"), "cost" => (int)$mysidia->input->post("cost"), "genderratio" => (int)$mysidia->input->post("genderratio")]);
Finally, we still need to modify the adoptable creation form in ACP to add a textfield for gender ratio. Simply go to /view/admincp/adoptview.php and locate these lines of code(starting at line 108 for unmodified code, inside method AdoptView::add()):
PHP:
$adoptForm->add($basicInfo);
$adoptForm->add($shopSettings);
$adoptForm->add($conditions);
$adoptForm->add($miscellaneous);
$adoptForm->add(new Button("Create this Adoptable", "submit", "submit"));
$document->add($adoptForm);
And add the following code above these lines(actually it actually does not matter if you mistakenly inserted these lines below instead, thats the beauty of OOP and GUI!):
PHP:
$miscellaneous->add(new Comment("The Gender Ratio of your adoptable is ", FALSE));
$miscellaneous->add(new TextField("genderratio", 50));
So this marks the end of manual installation process, hopefully its not much more complicated than last time(just the query for acp_hooks is new addition, as I've decided that admins can enable/disable this mod in ACP)? I hope you enjoy the Mods I am making for the script, I've decided to work on a few more new plugins for the script in the next few days. Lemme know if you have any suggestions to make, please do lemme know.