Hall of Famer
01-25-2014, 09:07 AM
Well since I've had some new users requesting this plugin, I decide that its necessary to make a Mys v1.3.4 compatible version of the Gender Ratio Mod. I've included an rar file at the end of this post for you to download the files, make sure to enter the directory /install and execute the file /install/genderratio.php so that the column genderratio will be inserted successfully into the database.
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. It is quite easy, and requires less script edits than the older version.
Anyway, to begin with, insert the column genderratio into your table prefix.adoptables. Its type is INT, default value should be 50:
'genderratio', INT( 11 ), default 50
After this is done, go to your script file /admincp/view/adoptview.php, and find the following code:
$adoptForm->add($basicInfo);
$adoptForm->add($shopSettings);
$adoptForm->add($conditions);
$adoptForm->add($miscellaneous);
$adoptForm->add(new Button("Create this Adoptable", "submit", "submit"));
$document->add($adoptForm);
Add above:(it actually does not matter if you mistakenly inserted these lines below instead, thats the beauty of OOP and GUI!)
$miscellaneous->add(new Comment("The Gender Ratio of your adoptable is ", FALSE));
$miscellaneous->add(new TextField("genderratio", 50));
Before closing this file, find the sql insertion query for prefix.adoptables at:
$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")));
Okay now go to admincp/adopt.php, and replace this chunk of code with:
$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")));
You may now close this /admincp/adopt.php file. The very next thing to do is to open a file located at /classes/class_adoptable.php. First of all, find a list of properties for this class at:
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;
Replace by:
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;
Perfect, we only have one last thing to do before this is all completed. Find the gender determination code at:
public function getGender(){
$genders = array('f', 'm');
$rand = rand(0,1);
return $genders[$rand];
}
Replace by:
public function getGenderRatio(){
return $this->genderratio;
}
public function getGender(){
$genderNumber = rand(0, 99);
if($genderNumber < $this->genderratio) $gender = "f";
else $gender = "m";
return $gender;
}
The only difference between the Mys v1.3.3 and v1.3.4 version is that the adopt.php file in ACP is now split into two separate files. For this reason, you need to edit two files, not just one. Some users may have figured it out on their own, its a good thing.
This is a reusable method, which means that both adopt.php and breeding.php can make use of it without writing the same block of code twice. Another reason why OOP pwns.
So this marks the end of manual installation process, its a lot simpler than last time isnt it? Anyway 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.
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. It is quite easy, and requires less script edits than the older version.
Anyway, to begin with, insert the column genderratio into your table prefix.adoptables. Its type is INT, default value should be 50:
'genderratio', INT( 11 ), default 50
After this is done, go to your script file /admincp/view/adoptview.php, and find the following code:
$adoptForm->add($basicInfo);
$adoptForm->add($shopSettings);
$adoptForm->add($conditions);
$adoptForm->add($miscellaneous);
$adoptForm->add(new Button("Create this Adoptable", "submit", "submit"));
$document->add($adoptForm);
Add above:(it actually does not matter if you mistakenly inserted these lines below instead, thats the beauty of OOP and GUI!)
$miscellaneous->add(new Comment("The Gender Ratio of your adoptable is ", FALSE));
$miscellaneous->add(new TextField("genderratio", 50));
Before closing this file, find the sql insertion query for prefix.adoptables at:
$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")));
Okay now go to admincp/adopt.php, and replace this chunk of code with:
$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")));
You may now close this /admincp/adopt.php file. The very next thing to do is to open a file located at /classes/class_adoptable.php. First of all, find a list of properties for this class at:
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;
Replace by:
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;
Perfect, we only have one last thing to do before this is all completed. Find the gender determination code at:
public function getGender(){
$genders = array('f', 'm');
$rand = rand(0,1);
return $genders[$rand];
}
Replace by:
public function getGenderRatio(){
return $this->genderratio;
}
public function getGender(){
$genderNumber = rand(0, 99);
if($genderNumber < $this->genderratio) $gender = "f";
else $gender = "m";
return $gender;
}
The only difference between the Mys v1.3.3 and v1.3.4 version is that the adopt.php file in ACP is now split into two separate files. For this reason, you need to edit two files, not just one. Some users may have figured it out on their own, its a good thing.
This is a reusable method, which means that both adopt.php and breeding.php can make use of it without writing the same block of code twice. Another reason why OOP pwns.
So this marks the end of manual installation process, its a lot simpler than last time isnt it? Anyway 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.