Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Mys v1.2.x Mods (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=38)
-   -   Hall of Famer's Gender Ratio Mod v1.2 (http://www.mysidiaadoptables.com/forum/showthread.php?t=2353)

Hall of Famer 08-28-2011 05:46 AM

Hall of Famer's Gender Ratio Mod v1.2
 
1 Attachment(s)
Well it is finally time to upgrade my old Mods to Mys v1.2.x compatible version. The first one I am doing is this Gender Ratio Mod, since its rather simple. The evolution Mod will be done after I complete ACP-Integration for Itemshop, it will use the plugin system just like Kaeliah's Multi-Adopt Image engine.

To start off, I am assuming you guys/gals know how to add columns in tables? Well it does not matter if you dont, just run the script called install_genderratio.php on your site and delete it. Anyway create a new column at the end of table prefix.adoptables:

PHP Code:

'genderratio'INT11 )', default 50 

Next, go to admin.php and find the following lines:

PHP Code:

                                            <p>Alternate Outcomes Selection Information:</p>
                                            <
p>
                                                
Start using the alternate outcome at level number
                                                <
input name='altoutlevel' type='text' id='altoutlevel' size='6' maxlength='6'>
                                                <
br />
                                                (Use 
Level 0 to have the alternate outcome be used from birthThis will not affect the first egg image.)
                                            </
p>
                                            <
p>
                                                
The alternate outcome has a chance of 1 in 
                                                
<input name='altchance' type='text' id='altchance' size='6' maxlength='6'>
                                                
of being selected.<br />
                                                (
Here you can select the chance that the alternate images for this adoptable are used
                                                
So, for an equal chance of using say male or female images
                                                
put 2 in the box to have a 1 out of 2 or 50chance of using the alternate image
                                                If 
you want to have the alternate images be rare images, use a higher number
                                                
like 100 for a 1 out of 100 chance of using the alternates.)
                                            </
p>
                                            <
p>
                                                <
input type='submit' name='Submit' value='Create This Adoptable'
                                            </
p>
                                        </
form>"; 

Replace with:

PHP Code:

 <p>Alternate Outcomes Selection Information:</p>
                                            <
p>
                                                
Start using the alternate outcome at level number
                                                <
input  name='altoutlevel' type='text' id='altoutlevel' size='6'  maxlength='6'>
                                                <
br />
                                                (Use 
Level 0 to have the  alternate outcome be used from birthThis will not affect the first /  egg image.)
                                            </
p>
                                            <
p>
                                                
The alternate outcome has a chance of 1 in 
                                                
<input name='altchance' type='text' id='altchance' size='6' maxlength='6'>
                                                
of being selected.<br />
                                                (
Here you can select the  chance that the alternate images for this adoptable are used
                                                
So, for an equal chance of using say male or female images
                                                
put 2 in the box to have  a 1 out of 2 or 50chance of using the alternate image
                                                If 
you want to have the alternate images be rare images, use a higher number
                                                
like 100 for a 1 out of 100 chance of using the alternates.)
                                            </
p>
                          <
p>The Gender Ratio of your adoptable is 
                          
<input name='genderratio' type='text' id='genderratio' size='6' maxlength='6'
                          <
p>
                                            <
p>
                                                <
input type='submit' name='Submit' value='Create This Adoptable'
                                            </
p>
                                        </
form>"; 

Now you will have to edit nadopt.php to ensure the value entered for genderratio will appear in database. Find:

PHP Code:

        $alternates $_POST["alternates"];
        
$altoutlevel $_POST["altoutlevel"];
        
$altchance $_POST["altchance"]; 

Add below:
PHP Code:

        $genderratio $_POST["genderratio"]; 

Also in nadopt.php, find the following codes:

PHP Code:

            runquery("INSERT INTO {$prefix}adoptables VALUES ('', '{$name}', '{$class}' ,'{$description}','{$eggimage}','{$cba}','{$promocode}', '{$freqcond}', '{$number}','{$datecond}','{$date}','{$adoptscond}','{$maxnumcond}','{$morethannum}','{$usergroupcond}','{$usergroups}','{$alternates}','{$altoutlevel}','{$altchance}', '{$cost}')"); 

Replace with:

PHP Code:

            runquery("INSERT INTO {$prefix}adoptables VALUES ('',  '{$name}', '{$class}'  ,'{$description}','{$eggimage}','{$cba}','{$promocode}', '{$freqcond}',  '{$number}','{$datecond}','{$date}','{$adoptscond}','{$maxnumcond}','{$morethannum}','{$usergroupcond}','{$usergroups}','{$alternates}','{$altoutlevel}','{$altchance}',  '{$cost}', '{$genderratio}')"); 

You are done with nadopt.php, but the game is not over yet. We have yet to add the gender generation script. To do this, open doadopt.php and find the following lines:

PHP Code:

                        $genders = array('f''m');
                        
$rand rand(0,1);
                        
                        
runquery("INSERT INTO {$prefix}owned_adoptables VALUES ('', '{$row['type']}', '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no', '$genders[$rand]','0')"); 

Replace the entire text with:

PHP Code:

$tempgender rand(099);
if(
$tempgender $row['genderratio']) {
$gender "f";
unset(
$tempgender);
}
else {
$gender "m";
unset(
$tempgender);
}
runquery("INSERT INTO {$prefix}owned_adoptables VALUES ('',  '{$row['type']}', '$name','$loggedinname','0','0', '$code',  '','$alts','fortrade','no', '$gender','0')"); 

This should do the trick. I've uploaded the file install_genderratio.php, run it on your site to add column genderration in only one step. Note the range of gender ration is between 0 to 100. A gender ratio of 0 means the adoptable is 100% male, a gender ratio of 100 means the adoptable is 100% female. The adoptable has equal chance to be male or female if the value is set to be 50.

Hall of Famer

Linkin-Dreamer 08-28-2011 08:36 AM

:O Neat! I might use this, it looks really good!

SilverDragonTears 08-28-2011 04:47 PM

Wait what's the difference with this and the current gender ratio?

Hall of Famer 08-28-2011 05:17 PM

umm there is no gender ratio feature for an official release. I am assuming you are talking about the old gender ratio script I made for Mys v1.1.x? Well there aint a big difference, just this one is for Mys v1.2.x and the old one may not be compatible with latest release.

SilverDragonTears 08-28-2011 05:26 PM

oh what's it do?

Hall of Famer 08-28-2011 05:30 PM

With the gender ratio script you can set the ratio of male and female for a certain species, it can even be 100% male or 100% female.

SilverDragonTears 08-28-2011 05:31 PM

ohhhhhhhhhhhh nice!!

Hall of Famer 08-28-2011 05:50 PM

Thanks for your comment, you are again more than welcome to test the code on your site to see if it works for you.

SilverDragonTears 08-28-2011 05:57 PM

I will eventually... .I don't think I have use for it at the moment... but I'm sure I will soon.

Hall of Famer 08-29-2011 04:51 PM

Alright, you may use it at anytime you want. There is a chance that I may update the script once Mys v1.3.0 is released. Also the Gender Ratio Mod v1.2 fixed a flaw in the old script. It may take some time to explain, I will tell you if you want to.


All times are GMT -5. The time now is 07:58 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.