Mysidia Adoptables Support Forum  

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

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 11-24-2010, 03:46 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 492,674
Hall of Famer is on a distinguished road
Default Hall of Famer's gender ratio system

Well this one is based on Arianna's gender mod. As far as I know, Kaeliah already has a gender ratio/chance system before I made this one, so I do not take any credits for this script. Dont forget to credit Arianna though, she was the first one to bring up this excellent gender idea that Rusnak Adoptables were originally, lacking.

Before you proceed, make sure you you have Arianna's gender system on your script already. Her thread can be found here:
http://www.rusnakweb.com/forum/showthread.php?tid=1367&page=1

It is rather straight forward to follow Arianna's mod-installation guide, so I wont explain much. The script simply defines a new variable Gender, which is a random number that has 50-50 chance of being male or female. The myadopts.php also displays an adoptable's gender. For those of you who do not know how to add a gender column to the 'owned_adoptables' table, I've attached this screenshot below for you to follow the instruction. Shouldnt be hard though, there's no coding involved:




Alright lets get started on this gender ratio system. Before we proceed, it is necessary to add a new column called 'genderratio' to the table adoptables. Its strongly advised that you add it to the last column.

After this is done, go to admin.php and find the codes below:

PHP Code:
 <hr>
  <
p><strong>Alternate Outcomes Settings:</strong></p>
  <
p>This section allows you to set if you want to enable alternate outcomesThis setting allows you to specify what the chances are of a user getting an alternate or special version of this adoptableCheck the checkbox below to enable this feature and then fill out the information below.. </p>
  <
p><strong>
    <
input name='alternates' type='checkbox' id='alternates' value='enabled'>
</
strong>Enable Alternate Outcomes </p>
  <
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 usedSo, for an equal chance of using say male or female imagesput 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 numberlike 100 for a 1 out of 100 chance of using the alternates.)</p>
  <
p>
    <
input type='submit' name='Submit' value='Create This Adoptable'
  </
p>
  <
p>&nbsp; </p>
</
form>"; 
Select and replace the entire codes with:

PHP Code:
<hr>
  <
p><strong>Alternate Outcomes Settings:</strong></p>
  <
p>This section allows you to set if you want to enable alternate outcomesThis setting allows you to specify what the chances are of a user getting an alternate or special version of this adoptableCheck the checkbox below to enable this feature and then fill out the information below.. </p>
  <
p><strong>
    <
input name='alternates' type='checkbox' id='alternates' value='enabled'>
</
strong>Enable Alternate Outcomes </p>
  <
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 usedSo, for an equal chance of using say male or female imagesput 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 numberlike 100 for a 1 out of 100 chance of using the alternates.)</p>
  <
p>
  <
p>The Gender Ratio of your adoptable is 
  
<input name='genderratio' type='text' id='genderratio' size='6' maxlength='6'
  <
p>
<
input type='submit' name='Submit' value='Create This Adoptable'
  </
p>
  <
p>&nbsp; </p>
</
form>"; 

You can see that we add codes for gender ratio in admin control panel, so you will be able to define gender ratio in acp instead of going all the way to PHPmyadmin. You will have to modify nadopt.php next, otherwise you will not be able to create new adoptables!



In nadopt.php, find:

PHP Code:
$alternates $_POST["alternates"];
$alternates secure($alternates);

$altoutlevel $_POST["altoutlevel"];
$altoutlevel secure($altoutlevel);

$altchance $_POST["altchance"];
$altchance secure($altchance); 
Add below:

PHP Code:
$genderratio $_POST["genderratio"];
$genderratio secure($genderratio); 
Also find the sql commands in this script file:

PHP Code:
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxnumcond','$morethannum','$usergroupcond','$usergroups','$alternates','$altoutlevel','$altchance')"); 
Replace with:

PHP Code:
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxnumcond','$morethannum','$usergroupcond','$usergroups','$alternates','$altoutlevel','$altchance','$genderratio')"); 


Alright now we are done with nadopt.php. This isnt over yet, we will have to add codes for the actual gender ratio system. In doadopt.php, find:

PHP Code:
$name $_GET["name"];
$name preg_replace("/[^a-zA-Z0-9\\040.]/"""$name);
$name secure($name); 
Add below:

PHP Code:
$genderratio $_GET["genderratio"];
$genderratio preg_replace("/[^a-zA-Z0-9\\040.]/"""$genderratio);
$genderratio secure($genderratio); 
This is how we define the variable $genderratio in doadopt.php. Note this ratio must be an integer. After you complete this step, find:

PHP Code:
$aid=@mysql_result($result,$i,"id"); //The adoptable's ID
$type=@mysql_result($result,$i,"type");
$description=@mysql_result($result,$i,"description");
$eggimage=@mysql_result($result,$i,"eggimage"); 
Add below:

PHP Code:
$genderratio=@mysql_result($result,$i,"genderratio"); 
This is how we retrieve data from sql. Here comes the fun, I promise it does. Search for the codes below:

PHP Code:
//The gender mod
$tempgender rand(01);
if(
$tempgender == "0") {
$gender "Female";
unset(
$tempgender);
}
else {
$gender "Male";
unset(
$tempgender);

Yes this is Arianna's gender mod. You will have to install it before using my gender ratio script. We are going to replace Arianna's gender determination system with this gender ratio system. So select the codes and replace with:

PHP Code:
//The gender mod
if($genderratio >= and $genderratio 101) {
$tempgender rand(0100);
if(
$tempgender >= and $tempgender $genderratio) {
$gender "Female";
unset(
$tempgender);
}
else {
$gender "Male";
unset(
$tempgender);
}
}
else {
$gender "Genderless";


So yes, we are all set now. Isnt this easy? Well there is a flaw in this code that the gender ratio is actually not 50-50 when you set the gender ratio to be 50. This is because there are actually 101 integers between 0 to 100. One way to solve this problem is to use another if-else statement that deals with gender ratio = 50, another way is to increase the gender ratio maximum from 100 to 1000, or even 10000. This may sound confusing, but please give a try if you are an aspiring coder.

Also, keep in mind that this is actually female gender ratio, not male gender ratio. A gender ratio of 80 typically tells us that you have 80% chance to get female adoptable, and 20% chance of getting male adoptable. Similarly, a gender ratio of 15 means that you only have 15% chance to get a female adoptable. What if you enter a gender ratio above 100? Well, if you actually look into the codes I wrote, I define it as genderless and such cases may exist for adoptables like Magnemite and Shellder in pokemon series. Make good use of it if you can. Here is an example of my genderless Magnemite:


Thats the end of it. Sorry I wrote a lot, and thanks for taking the time and trouble to go through the entire article. I hope it helps.

Hall of Famer
Reply With Quote
  #2  
Old 11-25-2010, 02:25 AM
PTGigi's Avatar
PTGigi PTGigi is offline
Crazily Friendly~HoF
 
Join Date: Jul 2009
Location: Somewhere >.>
Posts: 370
Gender: Female
Credits: 31,248
PTGigi
Default RE: Hall of Famer's gender ratio system

Oh very nice :D I was wondering how to do something like this and thought out a not very good way to do it XD Nice of you to think of a better way. :D I'll be sure to test this out when I can get the time, thank you very much! =3
__________________


"I see now that the circumstances of one's birth are irrelevant; it is what you do with the gift of life that determines who you are."~Mewtwo
My Adoptables|Nuzlocke Webcomic
Reply With Quote
  #3  
Old 11-25-2010, 02:58 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 492,674
Hall of Famer is on a distinguished road
Default RE: Hall of Famer's gender ratio system

You are very welcome, glad you like it. ^^

Like I've pointed out before, there's still a small problem with the formula used to calculate gender ratio. There are 101 integers between 0 to 100, not 100. Because of this, it is impossible to achieve 50-50 chance for male or female adoptables(it will be 51-50 instead). There are ways to fix this I am sure, and one easy approach is to set the range of Gender ratio to be 0-99 or 1-100, but then it will lead to confusion of the definition of Gender Ratio. *sigh*

Also if you are running a pokemon site and you want genderless pokemon such as Magnemite, the script does a good job for you. All you have to do is to enter a gender ratio outside of the range 0-100. I did 101 for my pokemon such as Magnemite and Voltorb, but you can even try 1000 if you want to. The adoptable you get will always be genderless then.
Reply With Quote
  #4  
Old 11-25-2010, 04:04 AM
PTGigi's Avatar
PTGigi PTGigi is offline
Crazily Friendly~HoF
 
Join Date: Jul 2009
Location: Somewhere >.>
Posts: 370
Gender: Female
Credits: 31,248
PTGigi
Default RE: Hall of Famer's gender ratio system

Quote:
Originally Posted by Hall of Famer
Also if you are running a pokemon site and you want genderless pokemon such as Magnemite, the script does a good job for you. All you have to do is to enter a gender ratio outside of the range 0-100. I did 101 for my pokemon such as Magnemite and Voltorb, but you can even try 1000 if you want to. The adoptable you get will always be genderless then.
Lol did my name give it away? XD Thank you for that too :D It will most certainly come in handy =3
__________________


"I see now that the circumstances of one's birth are irrelevant; it is what you do with the gift of life that determines who you are."~Mewtwo
My Adoptables|Nuzlocke Webcomic
Reply With Quote
  #5  
Old 11-25-2010, 03:50 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 492,674
Hall of Famer is on a distinguished road
Default RE: Hall of Famer's gender ratio system

Well yeah, a Pokemon trainer. XD

And you are welcome, just use my script if its available for public. I am actually not even half as good as Kaeliah when it comes to PHP coding, and if you ever encounter glitches please lemme know.
Reply With Quote
  #6  
Old 11-28-2010, 12:39 AM
PTGigi's Avatar
PTGigi PTGigi is offline
Crazily Friendly~HoF
 
Join Date: Jul 2009
Location: Somewhere >.>
Posts: 370
Gender: Female
Credits: 31,248
PTGigi
Default RE: Hall of Famer's gender ratio system

Quick question, to get an all female or all male you use 0 and 100 right? 0 for all male and 100 for all female?

Also couldn't you change $tempgender = rand(0, 100); to $tempgender = rand(1, 100); to erase the 50-51 problem? =3 (not sure just started PHP X3)
__________________


"I see now that the circumstances of one's birth are irrelevant; it is what you do with the gift of life that determines who you are."~Mewtwo
My Adoptables|Nuzlocke Webcomic
Reply With Quote
  #7  
Old 11-28-2010, 02:25 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 492,674
Hall of Famer is on a distinguished road
Default RE: Hall of Famer's gender ratio system

Quote:
Originally Posted by pokemontrainergigi
Quick question, to get an all female or all male you use 0 and 100 right? 0 for all male and 100 for all female?

Also couldn't you change $tempgender = rand(0, 100); to $tempgender = rand(1, 100); to erase the 50-51 problem? =3 (not sure just started PHP X3)
Since this is a female gender ratio script, I'd say 100 = all female and 0 = all male.

Well yeah, you can technically change that to as simple as 0 to 9. The problem is that most people are used to the idea of having a range of ratio/percentage between 0 to 100, but sure you can do that. ^^
Reply With Quote
  #8  
Old 12-24-2010, 10:59 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 492,674
Hall of Famer is on a distinguished road
Default RE: Hall of Famer's gender ratio system

Oh btw, Arianna's gender mod is added in RA version 1.1, so you do not have to install any pre-requisites if you use RA version 1.1. Simply follow the rest of the steps as I provided a few weeks ago and you should have a fully functioning gender ratio system. ^^

Merry Christmas everyone!

Hall of Famer
Reply With Quote
  #9  
Old 01-24-2011, 02:06 AM
RoconzaArt's Avatar
RoconzaArt RoconzaArt is offline
Member
 
Join Date: Jan 2011
Location: NJ Shore (and proud of it)
Posts: 479
Gender: Female
Credits: 57,731
RoconzaArt is an unknown quantity at this point
Default

I'm getting this error:

Quote:
The ID specified does not match any adoptable in our system. Sorry. If you wish, you can adopt a pet.
Did I do some thing wrong?
__________________

Last edited by RoconzaArt; 01-24-2011 at 02:17 AM.
Reply With Quote
  #10  
Old 01-24-2011, 02:15 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 492,674
Hall of Famer is on a distinguished road
Default

Can you show me the tables prefix_adoptables and prefix_owned_adoptables from phpmyadmin? My initial guess is that your table structure is different so the sql query lines must be modified to account for this change.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
Reply


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mys v1.3.3 Gender Ratio Mod for Mys v1.3.3 Hall of Famer Mys v1.3.x Mods 17 05-23-2019 04:34 PM
Mys v1.3.2 Gender Ratio Mod for Mys v1.3.2 Hall of Famer Mys v1.3.x Mods 6 01-08-2013 03:02 PM
Mys v1.3.1 Gender Ratio Mod for v1.3.1 Hall of Famer Mys v1.3.x Mods 15 08-17-2012 04:25 AM
Hall of Famer's HP system Hall of Famer Mys v1.1.x Mods 13 04-25-2012 08:08 AM
Hall of Famer's Gender Ratio Mod v1.2 Hall of Famer Mys v1.2.x Mods 45 04-02-2012 01:42 PM


All times are GMT -5. The time now is 03:23 AM.

Currently Active Users: 1079 (0 members and 1079 guests)
Threads: 4,081, Posts: 32,032, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


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