Well my old gender ratio script is not compatible with the new script, so I decide to make a new one. It really isnt complicated, just a few minor edits and its up and running.
I've provided a zip file that contains all necessary modifications to make in your script file in order to get this to work. Incase you have a highly customized site, you may install this Mod manually by following the instruction below. To begin with, insert a new column into table
prefix.adoptables as usual:
PHP Code:
'genderratio', INT( 11 ), default 50
Since admin.php file does not exist nowadays, you need to go to the file
/admincp/adopt.php to modify the form. To add the input field Genderratio into adoptables creation form, find the following code below:
PHP Code:
</fieldset>
<p><input name='page' type='hidden' id='page' value='adopt'>
<input name='action' type='hidden' id='action' value='add'>
<input type='submit' name='submit' value='Create This Adoptable'></p></form>";
Add above
PHP Code:
<p>The Gender Ratio of your adoptable is
<input name='genderratio' type='text' id='genderratio' size='6' maxlength='6'> </p>
Continue in this script file, find these lines below:
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")));
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"), "genderratio => $mysidia->input->post("genderratio")"));
The next thing to do, of course, is to manually update our beloved
doadopt.php file to enable gender ratio to work while a user is trying to adopt a pet. Find these lines that determine adoptables gender:
PHP Code:
$genders = array('f', 'm');
$rand = rand(0,1);
$mysidia->user->changecash(-$row->cost);
$mysidia->page->settitle("{$name} adopted successfully");
$mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $row->type, "name" => $name, "owner" => $mysidia->user->username, "currentlevel" => 0, "totalclicks" => 0, "code" => $code,
"imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $genders[$rand], "lastbred" => 0));
Replace by the gender ratio generation code:
PHP Code:
$tempgender = rand(0, 99);
if($tempgender < $row->genderratio){
$gender = "f";
unset($tempgender);
}
else {
$gender = "m";
unset($tempgender);
}
$mysidia->user->changecash(-$row->cost);
$mysidia->page->settitle("{$name} adopted successfully");
$mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $row->type, "name" => $name, "owner" => $mysidia->user->username, "currentlevel" => 0, "totalclicks" => 0, "code" => $code,
"imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $gender, "lastbred" => 0));
If you want the gender ratio script to work with breeding, you will have to do one last task. The below edit is not required, but for those who want pets gender ratio to take effect on breeding. To do this, you need to go to
breeding.php and find the following lines:
PHP Code:
$genders = array('f', 'm');
$genderrand = rand(0,1);
// Get other related information
$code = codegen(10, 0);
$alts = getaltstatus($female_species->id, 0, 0);
$time = time();
// Insert a baby adoptable to the database
$mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $types[$typerand], "name" => $types[$typerand], "owner" => $mysidia->user->username, "currentlevel" => 0, "totalclicks" => 0, "code" => $code,
"imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $genders[$genderrand], "lastbred" => 0));
Replace with:
PHP Code:
$genderratio = ($typerand == 0)?$female_species->genderratio:$male_species->genderratio;
$tempgender = rand(0, 99);
if($tempgender < $genderratio){
$gender = "f";
unset($tempgender);
}
else {
$gender = "m";
unset($tempgender);
}
// Get other related information
$code = codegen(10, 0);
$alts = getaltstatus($female_species->id, 0, 0);
$time = time();
// Insert a baby adoptable to the database
$mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $types[$typerand], "name" => $types[$typerand], "owner" => $mysidia->user->username, "currentlevel" => 0, "totalclicks" => 0, "code" => $code,
"imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $gender, "lastbred" => 0));
Now we are all done, it is just this simple isnt it? Like I mentioned earlier I've uploaded a zip file containing all modified scripts for those who are running a fresh installation of Mysidia Adoptables. Note you can only use them if you have not heavily modified your script files. The install_genderratio.php file needs to be executed to insert the column genderratio(INT 11) automatically to your database, although you can again do it manually. Enjoy!