Log in

View Full Version : Breeding System - Complete!


Arianna
10-29-2009, 02:33 PM
Firstly, I don't take credit for all this. This code was made by gabeki, Seapyramid, Brandon, and me. :D

You'll need to have some kind of gender mod for this, so viewing the thread that I have would be very useful. ;)

Just copy and paste the file at the bottom of this post into a file and call it 'breeding.php'. Then upload it via FTP or FileManager to your website, in the 'adoptables' folder (or whatever else you called it).

There are a few things you'll need to change - if you don't have a date system like me, take out the following part on line 204.
$date = date("F jS, Y");

Then find and replace.
//find this code, around line 207 or 208
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no','$gender','$date')");
//replace it with this
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no','$gender',)");

If you don't have a trade system or plan to install one, you can change 'fortrade' to 'notfortrade', though it is not nessecary.

The last thing you need is a link to the breeding page. You can put it in the top nav bar (I do that via PHPmyAdmin) or in the sidebar (functions.php) but make sure your members have some way to access it.

Tell me if there is anything left which is wrong with the code, please!

<?php

// ************************************************** ********************
// Rusnak PHP Adoptables Script
// Copyright 2009 Brandon Rusnak
// For help and support: http://www.rusnakweb.com/forum/
//
// Redistribution prohibited without written permission
// ************************************************** ********************

// Wake the sleeping giant

// ************************************************** ********************
// Basic Configuration Info
// ************************************************** ********************

include("inc/functions.php");
include("inc/config.php");

$themeurl = grabanysetting("themeurl");

// ************************************************** ********************
// Define our top links by calling getlinks()
// ************************************************** ********************

$links = getlinks();

// ************************************************** ********************
// Define our ads by calling getads()
// ************************************************** ********************

$ads = getads("any");

// ************************************************** ********************
// Grab any settings that we will need for the current page from the DB
// ************************************************** ********************

$browsertitle = grabanysetting("browsertitle");
$sitename = grabanysetting("sitename");
$slogan = grabanysetting("slogan");

// ************************************************** ********************
// Check and see if the user is logged in to the site
// ************************************************** ********************

$loginstatus = logincheck();
$isloggedin = $loginstatus[loginstatus];
$loggedinname = $loginstatus[username];

// ************************************************** ********************
// End Prepwork - Output the page to the user
// ************************************************** ********************


$article_content = $article_title."Breeding System";
$article_content = $article_content."<p>Adoptable breeding systems sure aren't easy to make! I wish that this would work!</p>";

$femaleid = $_POST['female'];
$maleid = $_POST['male'];
$breed = $_POST['breed'];

$femaleid = secure($femaleid);
$maleid = secure($maleid);
$breed = secure($breed);

// this two variables will get the female and male ID's from the selection form and the answer if the user has selected the adoptables or not.

// First let's create a page so the users can choose the two adoptables that they want to breed

if ($isloggedin == "yes"){
// we have to put that in the start of the breeding system, so users that are not logged in cannot see the selection forms

if ($breed != 'yes'){
// if the anser if the user has selected the adoptables or not, is different than YES, we have to show the options so the user can select them

// This will start a selection form to select the females
$article_content = $article_content."<p>Select the Two adoptables you want to Breed:</p><p><form method='post'><select name = 'female'>";

//This will select all the female adoptables the user has
$result = mysql_query("SELECT * FROM ".$prefix."owned_adoptables WHERE owner = '$loggedinname' AND gender = 'Female'");
$num = mysql_num_rows($result);

// Loop Out code < this will loop so you select all the rows and not just one
$i = 0;
while ($i < $num){
$aid = @mysql_result($result,$i,'aid');
$type = @mysql_result($result,$i,'type');
$name = @mysql_result($result,$i,'name');

$article_content = $article_content."<option value='".$aid."'>".$name." (".$type.")</option>";
//this will display something like that: cute kitty (cat), the name (the type); for each adoptable (female) the user has

$i++;
}

$article_content = $article_content."</select><select name='male'>"; //now let's do the same for the males

$result2 = mysql_query("SELECT * FROM ".$prefix."owned_adoptables WHERE owner = '$loggedinname' AND gender = 'Male'");
$num2 = mysql_num_rows($result2);

// Loop Out code
$i2 = 0;
while ($i2 < $num2){
$aid2 = @mysql_result($result2,$i2,'aid');
$type2 = @mysql_result($result2,$i2,'type');
$name2 = @mysql_result($result2,$i2,'name');

$article_content = $article_content."<option value='".$aid2."'>".$name2." (".$type2.")</option>";

$i2++;
}

$article_content = $article_content."</select><input type='hidden' name='breed' value='yes'><input type='submit' value='Breed It'></form>";

// ok now the user has two selection forms to those a female and a male adoptable and when they click Breed It, it will be posted
// to the variables $_POST['female'] and $_POST['male'], which will be two aid (adoptables ids), and with that ID we can select
// the information that we need from the database, and breed them

// the hidden input will give us an answer to our question, the user has selected it? and it'll be 'yes'

} // this is the end of if($breed != 'yes'), so now we have to put an ELSE statment, that means that the answer IS yes, and we can proceed with the breeding

else {
// ok, if the user gets here, it means that we have the male and female ID, and with it we can select the informations from the database.
// here you can estabilish what you want.. the adoptables have to be which level to breed? the adoptables have to be the same type?
// I took out the incompatible part, it can be added back in if needed
// first let's get the information we need

$result = mysql_query("SELECT * FROM ".$prefix."owned_adoptables WHERE aid = '$femaleid'");
// the result should be just one row, so we don't need a loop

$female_type = mysql_result($result,0,'type');
// 0 means that we are selecting the very first row, in this case, the only one
$female_name = mysql_result($result,0,'name');
$female_level = mysql_result($result,0,'currentlevel');


$result2 = mysql_query("SELECT * FROM ".$prefix."owned_adoptables WHERE aid = '$maleid'");
// the result should be just one row, so we don't need a loop

$male_type = @mysql_result($result2,0,'type');
// 0 means that we are selecting the very first row, in this case, the only one
$male_name = @mysql_result($result2,0,'name');
$male_level = @mysql_result($result2,0,'currentlevel');

// now we have all we need. let's start the security system, to guarantee that the user has the requirements

if ($male_level < 2 OR $female_level < 2){ //this is if they can't breed
$article_content = $article_content."Sorry, one of your adoptables don't have the minimum level to breed. Keep feeding them so they can grow.";
}

else {
//We choose the type!
$temptype = rand(0, 1);
if($temptype == "0") {
$type = $male_type;
unset($temptype);
}
else if($temptype = "1"){
$type = $female_type;
unset($temptype);
}

if ($type == $male_type) {
$result3 = mysql_query("SELECT * FROM ".$prefix."adoptables WHERE type='$male_type'");
$aid = mysql_result($result3,0,"id"); //The adoptable's ID
$eggimage = mysql_result($result3,0,"eggimage");
}

else {
$result3 = mysql_query("SELECT * FROM ".$prefix."adoptables WHERE type='$female_type'");
$aid = mysql_result($result3,0,"id"); //The adoptable's ID
$eggimage = mysql_result($result3,0,"eggimage");
}

// we're choosing a gender


$tempgender = rand(0, 1);

if($tempgender == "0"){
$new_name = "Son of ".$male_name." & ".$female_name;
$gender = 'Male';
}
else if($tempgender == "1"){
$new_name = "Daughter of ".$male_name." & ".$female_name;
$gender = 'Female';
}

unset($tempgender);

$article_content = $article_content."<p>Your adoptables are breeding.</p>";

if ($type != "0"){
$article_content = $article_content."<p>Result: <b>Bred Succesfully</b></p><p>Your new egg is being transferred to you right now. Yay!</p>";

// now let's insert the new egg at owned_adoptables


// now we're choosing the code
$code = rand(1, 20000);

$alts = getaltstatus($aid, 0, 0);

// and the date comes in here too
$date = date("F jS, Y");

$name = $new_name;

mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no','$gender','$date')");

$article_content = $article_content."<p><img src='".$eggimage."'><br /><a href='myadopts.php'>Manage ".$name." now!</a>
It's type is ".$type." and it was born on ".$date."! You can change its name to your liking.</p>";

unset($gender);
unset($type);

} // if our type is not equal to zero, this is where we continue. this is the end of the continuation.
} // we end the place where it goes on if the levels are ok
} //this bracket ends the else where we find the male/female id's
}// this is the end of if($isloggedin == "yes")

else { //this is the else of if($isloggedin == "yes")

$article_content = $article_content."You are not logged in. Please log in to breed.";

}


// ************************************************** ********************
// Begin Template Definition
// ************************************************** ********************

//Define our current theme
$file = $themeurl;

// Do the template changes and echo the ready template
$template = file_get_contents($file);

$template = replace(':ARTICLETITLE:',$article_title,$template) ;
$template = replace(':ARTICLECONTENT:',$article_content,$templ ate);
$template = replace(':ARTICLEDATE:',$article_date,$template);

$template = replace(':BROWSERTITLE:',$browsertitle,$template);
$template = replace(':SITENAME:',$sitename,$template);

//Define our links
$template = replace(':LINKSBAR:',$links,$template);

//Get the content for the side bar...

$sidebar = getsidebar();
$template = replace(':SIDEFEED:',$sidebar,$template);

//Get the ad content...
$template = replace(':ADS:',$ads,$template);

//Get the slogan info
$template = replace(':SLOGAN:',$slogan,$template);


echo $template;

// ************************************************** ********************
// End Template Definition
// ************************************************** ********************



?>

arlecchina
10-29-2009, 03:11 PM
Thanks gabeki, Seapyramid, Brandon, and Arianna! I'm not sure when I'll be be able to try this out, but I definitely will in the future. Thanks for posting this!

Arianna
10-29-2009, 03:20 PM
You're welcome. :D I hope that you like it!

gabeki
10-30-2009, 11:30 AM
Ari, do you have a trade system?

Arianna
10-30-2009, 12:56 PM
Yes. :D Sea was nice enough to give me the code. :) Is there any chance this is interfering with the breeding code?

gabeki
10-30-2009, 03:34 PM
what do you mean by interfering? are you with some error?

how does sea's trading system works? I'll have to remake my code and I need some ideas ^^

Seapyramid
10-30-2009, 09:02 PM
what do you mean by interfering? are you with some error?

how does sea's trading system works? I'll have to remake my code and I need some ideas ^^


Quite frankly, it seems to me if someone wants a code I haven't shared public they should ask me about it, not someone I gave it too....

Sea

Arianna
10-31-2009, 02:59 AM
I'm not giving her the code, I just thought that it might be somehow not working as she didn't have it on her install (because it might not take it if there are 'fortrades' in the table. Come to think of it, I don't think it checks, I just wanted to be sure.
By interfering, I meant that you not having it may be causing something. But IDK if that's how it works. [/php novice speak]

Seapyramid
10-31-2009, 04:23 AM
I wasn't impling anything on you Arianna.. Just saying that those who asked were asking the wrong person :)

Arianna
10-31-2009, 04:45 AM
Okay, that's good. :)
I can't wait to try out the system on my working site. (My pets haven't grown up yet. xD)

SieghartZeke
10-31-2009, 08:11 AM
but the code that you need top put on the 207 line......in what of file you need to add(doadopt?myadopt?what??I)

Arianna
10-31-2009, 12:23 PM
In the actual breeding.php file.

SieghartZeke
10-31-2009, 12:28 PM
Uhm... but i can change the file name with coupling.php???

gabeki
10-31-2009, 03:19 PM
Seapyramid, I did not ask for the code, can you read my post at least once, before saying something about it?

Thanks ^^

Or even better, even after you read it at least once, you can relax and THINK before you post. That way you can try to be less rude and more useful to people here in the Forum.

I read almost all the posts here in the adoptables forum, including yours, and seems to me that because you have a good site, with a good amout of members and scripts programmed by yourself, you think you can despise others members that are starting now. Well, it's not that way.

But, if you are rude not because you think you are something more than others members, but because of personal problems, I recommend yoga. And it doesn't mean I care about your stress or something, so no need to thank me. I just care about how I'm treated.

Arianna
11-01-2009, 05:25 AM
Uhm... but i can change the file name with coupling.php???

Sure, if you want to.

SieghartZeke
11-01-2009, 10:16 AM
ok....now i show this hen i go in the Coupling:
i show this on the top of the page:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a6518385/public_html/GcA/adoptables/breeding.php on line 81
WHY???

Arianna
11-02-2009, 02:08 AM
I don't know. Can you please be patient? Gosh, I don't even want to help if you're so impolite.

SieghartZeke
11-02-2009, 10:02 AM
Sorry...

Bloodrun
11-03-2009, 05:18 PM
I don't know. Can you please be patient? Gosh, I don't even want to help if you're so impolite.


Thank you for being polite Arianna. She brings up a very good point, she is spending her time maing this Modification because she wants too. She is even nice enough to help you install it.

SieghartZeke you act very impatiently in a lot of the threads you post in. I would like to ask you nicely to please be patient and to please show some respect.

Hall of Famer
11-05-2009, 12:32 PM
So this is an egg system? Excellent!

Arianna
11-06-2009, 02:18 PM
I'm sorry, I've been busy. I can try and troubleshoot, though.
Maybe, try changing it back to breeding.php. There may be some file links, which could be disrupting it. :)
Have you installed the gender system/given existing pets genders? I had to do it manually, by making the default value 'female', then changing the rest to male.

SieghartZeke
11-06-2009, 02:38 PM
err i dont have complted the gender system because in a part,when ichanged the code i can managae the new charatcer!

Seapyramid
11-06-2009, 02:48 PM
err i dont have complted the gender system because in a part,when ichanged the code i can managae the new charatcer!


That is why you are getting the error then. the script is looking for the gender in the database & it's not there.

Hall of Famer
11-06-2009, 04:34 PM
I installed this addon, and get the two warnings below:



Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in public_html/adoption/breeding.php on line 81

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in public_html/adoption/breeding.php on line 99


Dunno if the breeding system will still work. XD

SieghartZeke
11-07-2009, 06:03 AM
But when i add a code,4 the gender, i dont show the new adoptable!
And 4 the Sql ,i dont know where to put ...and what put.....

Arianna
11-07-2009, 09:16 AM
I don't get what you're trying to say now... Are you saying you're having problems with this code, or with the gender code?
Why don't you just add the gender table, give the pets genders, and see if the breeding system works. Then we can work on the inserting into the table/

SieghartZeke
11-07-2009, 12:06 PM
No with the breeding no....is the gender that give me problem!
When i add this code:


mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','notfortrade','no','$gender')");

The character that i adopt say that is not in the database...and sorry 4 the bad grammar but im italian and i have so many problme to traslate the word that i say.....

Then......i need to add a new table in owned adoptable...but i dont know what i need to put!

Seapyramid
11-07-2009, 12:16 PM
Adding a row to a table is quite easy & in the Breeding system it is listed how to set it. Please, just try to read and learn a bit so that you can understand at least some of what you are told. http://www.w3schools.com/PHP/php_mysql_intro.asp

Sea

Ashje
12-17-2009, 10:29 PM
Hi, Thank you for posting this. It's excellent. My problem is that once an egg is successfully bread ( is that the past tense of breed? Bread? Not the food bread T.T) it isn't transferred to the user's account. The only edit I've made is changing the required levels from 2 to 0. If you have time, could you please help? Oh and I'm using your gender system as well. Also very awesome.

Thanks,
Ashje =D

Arianna
12-18-2009, 12:44 AM
Cool! I don't know why - why don't you try this. After where it's supposed to insert it, write:
$article_content = $article_content . $query;
This will allow you to see your query, and check if something is going wrong. Maybe you don't have the same number of columns as I do (I have a date column, too) so you might want to check that.
==
Lol, I just noticed that we don't do that in the query. If you put it in an external string, you can echo it. For now, try removing '$date', from the sting.

Ashje
12-18-2009, 01:18 AM
I'll give it a shot, thanks for the help. XD

gjac1
12-18-2009, 11:40 AM
Arianna, how much work do you think it would be to add a cost system to this mod ??

At the moment members can just breed as many as they like but if it costs them credits then it will limit the amount they can breed :)

Arianna
12-18-2009, 01:02 PM
Not much, just send me a PM and I can try and get it to work, especially as that would be good for my site, too. :)

Ashje
12-21-2009, 04:23 PM
Hi Arianna,

I tried removing the date codes but it still isn't transferring the newly born adoptable to the user's account. If you could, please help.

Thanks,
Ashje.

Arianna
12-22-2009, 01:06 AM
Hmm... That still is very weird. Could you make a line, after it's supposed to insert it, which echoes the query (or goes $article_content = $article_content . $query;, I guess) and paste that in. We can compare it to your table, then, to see what's wrong. :)

Ashje
12-23-2009, 04:34 AM
Thank you,

I'll try it as soon as my FTP gets up and running again. :D I'm excited, I'm learning PHP. XD

So I would say...

$name = $new_name;

mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no','$gender')");
$article_content = $article_content . $query;
$article_content = $article_content."<p><img src='".$eggimage."'><br /><a href='myadopts.php'>Manage ".$name." now!</a>
It's type is ".$type." and it was born on ".$date."! You can change its name to your liking.</p>";


or


$name = $new_name;

mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no','$gender')");
$article_content = $article_content. $query."<p><img src='".$eggimage."'><br /><a href='myadopts.php'>Manage ".$name." now!</a>
It's type is ".$type." and it was born on ".$date."! You can change its name to your liking.</p>";


Thanks,
Ashje.

Arianna
12-23-2009, 04:38 AM
Hmm, maybe...
$query = "INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no','$gender')";
mysql_query($query);
$article_content = $article_content. $query."<p><img src='".$eggimage."'><br /><a href='myadopts.php'>Manage ".$name." now!</a>
It's type is ".$type." and it was born on ".$date."! You can change its name to your liking.</p>";

mapleblade
12-23-2009, 09:03 AM
well it works fine at me, butthe new adoptable egg doesnt show up in myadopts.php?

Arianna
12-23-2009, 10:17 AM
That's weird. Are you sure you have the right colums in your table?

Ashje
12-23-2009, 09:40 PM
Hi Arianna,
I tried that and it worked! The adoptables were being inserted into the database. Problem is, it was showing the query on the page. So I removed your edit and it stopped working again. So then I put
mysql_query($query);
back in but left out
$query.
and it hid the query but still inserted the new adopt into the database. I think that was the problem. Anyway, thank you for the support. The script is awesome. XD

Ashje

Arianna
12-24-2009, 01:50 AM
Thanks. :) I'm glad you got it working. The problem for me is I have so many columns in the database (dates, parents, lots of other stuff) that it's hard to make the code work for everyone on the first try.

Ashje
12-24-2009, 02:06 AM
Lol. Well, thanks for all the help. +repped. :D

Arianna
12-24-2009, 04:01 AM
Thanks. :)

SieghartZeke
12-24-2009, 04:24 PM
Uhm...i have a question..is possible to make different character from the breeding?
Becuase in my site i want make a little difference...

For esample:
Elesis
http://www.gca.netai.net/picuploads/gif/311a61e9f18e6312cea3c3eb263c7fac.gif
+
Ronan
http://www.gca.myadopts.com/picuploads/gif/2c30bf2563a60d9a1c56aac7a07ebf8d.gif
=
http://www.gca.myadopts.com/picuploads/gif/75c256c483866c6dab35a1f72551de84.gif
???

Arianna
12-25-2009, 03:15 AM
I don't think so, no. Sorry.

bokkun
12-26-2009, 09:25 AM
Actually, it is possible, but requires quite a big code addition
probably it would be best to create a function which looks up the combination of the id's
like pet 2+7 gives back pet 9
but that means you have to save those combinations somewhere(preferable the database)
and when there is no combination it should say that the pets won't mate
I'll take a look at it, but it seems to be annoyingly time-taking

Arianna
12-26-2009, 09:41 AM
The point is - if you have 20 pets, that's an additional 400 pets you need to make. And what about if those 400 kinds can breed?
I won't code something like it, it's simply to hard. I guess you could check for certain situations (if ($kind="Kind1")) and then determine it, but I'm not in the mood for that.

bokkun
12-26-2009, 11:48 AM
Yes, it would be pretty hard
It's just an idea, maybe there's some sort of way...
I'll play with the code a bit, maybe I'll find some way
anyway nice script, seems to work flawless on my server.

mapleblade
12-26-2009, 11:51 AM
maybe ill make in the future a nod on this mod to let the eggs breed once, im not sre if its gonna succeed but ill maybe gonna try :D

Roconza
01-22-2010, 12:00 PM
Ok, here is a question that has to do with the above asked question:

Can I in theory make a "group" if you will as a new attribute like "gender" or "species" and tell the script instead of species the parents from this "group" can breed despite species and produce a egg that's a random choice of the one of the parents species?

I want to try this out it should work in theory but my php skill are very limited.

Arianna
01-22-2010, 01:36 PM
maybe ill make in the future a nod on this mod to let the eggs breed once, im not sre if its gonna succeed but ill maybe gonna try :D

I have no idea what you mean.

Roconza, I guess you could. I don't have time to make it, maybe you can get someone else to try for you.

Seapyramid
01-23-2010, 12:16 AM
Ok, here is a question that has to do with the above asked question:

Can I in theory make a "group" if you will as a new attribute like "gender" or "species" and tell the script instead of species the parents from this "group" can breed despite species and produce a egg that's a random choice of the one of the parents species?

I want to try this out it should work in theory but my php skill are very limited.


basically you would have to make a new table with say 1-10 being possible for 1xb breeding ... 11-20 being possible for yxz breeding.. then set up limits on a random for each breeding pair possible... thne set those randoms to the ids in the table.. then when a randon is right have it insert into the owned_adoptables table...


Have Fun :)

Quillink
01-29-2010, 12:26 PM
Ok, here is a question that has to do with the above asked question:

Can I in theory make a "group" if you will as a new attribute like "gender" or "species" and tell the script instead of species the parents from this "group" can breed despite species and produce a egg that's a random choice of the one of the parents species?

I want to try this out it should work in theory but my php skill are very limited.


basically you would have to make a new table with say 1-10 being possible for 1xb breeding ... 11-20 being possible for yxz breeding.. then set up limits on a random for each breeding pair possible... thne set those randoms to the ids in the table.. then when a randon is right have it insert into the owned_adoptables table...


Have Fun :)

Wouldn't adding a "group" column to the owned_adoptable table and a random number generator in the breeding script work just as well?

E.g.
if ($dadgroup == $momgroup){

$pickspecies = rand(1,2);
if $pickspecies = 1 { $babyspecies = $dadspecies }
else { $babyspecies = $momspecies }

}
else{
return die("What were you thinking?? A walrus and a DUCK??")
}



Btw, do NOT copy/paste this. This is NOT real php, just an example. :P
Real php syntax would take me a lot longer to write - time I don't like to use at 2:30am. :S

Szymon
02-06-2010, 02:22 PM
can anybody re-upload? please i've got problem with breeding.php and funstions.php :|

SieghartZeke
03-30-2010, 06:42 AM
Why when i do the breeding,a nd i go to manage i dont show the new pet???

Missy Master
05-17-2010, 10:02 AM
I'd like to do something where there is like a 2 day "pregnancy" that happens before the new egg goes to the hatchery.

I think its a matter of applying a timing to this, but I am not sure how to do it--- and everything I have read is making it more confusing for me.

So basically, the result would be the egg/baby still, but only after a certain time frame, and not instantly!

Possibly the pregnant pets would have a special designation too, or whatever, so you could mark them.

thanks for the help, I have an idea how to do it, just adding timing, but not sure at all how to do it.

PokePets
07-26-2010, 09:57 AM
There is missing a part of the code.
Enter this;
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','notfortrade','no','$gender')");
After this;
// Now we actually process the adoption and add it to the database...
// We need a unique code for the adoptable so we can show it to the user when we're done here...

$code = rand(1, 20000);

;)
So works it fine for me.

myadopts
08-06-2010, 11:45 AM
sorry...i have a question.....How do you make a pet male or female...or do you just fake it..or not add it?

PokePets
08-06-2010, 12:18 PM
It's. set automatic.
Look at the post of tommyk1210;
http://www.rusnakweb.com/forum/showthread.php?tid=1367&highlight=gender

or do you mean that some adoptable only can be male/female/ etc. ?

myadopts
08-07-2010, 09:21 AM
oh..ill insert the code I get it know thanks:D ill give credit if i use it

redheadturkey
08-08-2010, 02:33 PM
anyone have any ideas on how to do a delay of the actual birth? like how to write the timing for it?

thanks!

heyeeyhe
08-09-2010, 09:49 AM
I think theres a part of the code that shows that... im trying to work on making a script with pet stats like on foopets:D

MikiHeart
08-09-2010, 10:38 PM
redheadturkey:
To do that, you would have to look into timing.
It would depend on how you want it done.
But I would suggest a countdown on the breeding page.
Then after that time, the user can get the pet.

Just thinking on it a little, I think you would have to have the pet created instantly like the script does.
But then have it so the pet isn't given to them, but the system.
So you make a clone of the owned_adoptables. but called it something like bred_adoptables.
You would have to add some extra fields, like who it belongs to and stuff.
Then say, since it has a date on it. You'd need to have a script that checks that date, and compares it to today's date. Then if the right time has passed, it gives the adopable to right owner. Then updates the 'created date' to the date of the day you're getting it.

Sounds really hard XD but I'm just bad at explaining things. I don't understand php with dates too much. But I'm sure you can do it.
You'd need to set up a cron, and have it run like once a day. Which will do all this work for you XD

Or, you could just have a countdown on the page, then once the countdown is over, it displays a button in which the user clicks, and it gives them their pet XD No need for cron then o-o

Raikalynx
09-11-2010, 09:00 AM
..I've tried several solutions suggested in this thread, and I just can't get the script to enter the new egg into the mysql database.

It works fine otherwise, and it's a really cool script!

..I'll go learn some PHP now, I hate not knowing anything about this XD

PokePets
09-11-2010, 10:01 AM
Look;

There is missing a part of the code.
Enter this;
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','notfortrade','no','$gender')");
After this;
// Now we actually process the adoption and add it to the database...
// We need a unique code for the adoptable so we can show it to the user when we're done here...

$code = rand(1, 20000);

;)
So works it fine for me.




;)

Raikalynx
09-11-2010, 10:05 AM
Thanks, but that's one of the solutions I tried..
the breeding now works correctly, the egg is being transferred into my adopts, but it keeps displaying the query on the new egg page and I can't get rid of it..

..just a minor nuisance me and future users will just have to live with, I guess..

Wrim
09-23-2010, 11:21 PM
Awesome script!

2 questions though.

The first inquiry is just a small bug, but I thought I'd ask. If I try to mate without having a second gender I get error-messages. Is there some way to block this by adding a "No male/female co-breeder available" message or something like that in the textbox?

Secondly, the new-born are born without names. It's really not a problem, I was just wondering if there's a way to put a placeholder name like 'Newborn' or something so it doesn't just say "Get stats for" and "Get BBCodes / HTML Codes for" in the pet management section.

That's all. Thanks for all the walkthroughs and all the help.

vexel
09-24-2010, 12:46 PM
The born name is - "Daughter of (mpther name) & (father name).
But if you haven't got gender system it doesn't work ;D

Wrim
09-24-2010, 12:58 PM
My mistake, used an old pet to breed, hence the no-name error. I did install the gender-system but I didn't change the old pets genders.

myadopts
09-28-2010, 05:52 PM
Link to one I made.. It has some problems but, a look of how it looks. file:///C:/Users/admin/documents/my%20web%20sites/breeding%20test.php

Teshia
09-28-2010, 06:43 PM
Sorry ma, but we can't actually view code that has been made on your home computer. You can try attaching the file or uploading it to a host so we can see it there.

Eloise519
10-01-2010, 04:53 AM
I wasn't impling anything on you Arianna.. ---------------

Hall of Famer
10-01-2010, 11:47 AM
umm is this a spammer?

Anyway, Arianna you are absolutely amazing for making such a script. I'm giving you the karma you should've gotten a long long time ago, thank you. ^^

Hall of Famer
10-14-2010, 11:49 PM
Oh btw, it would be nicer if there is a way to specify gender ratio for different species of adoptables. I will see what I can do with this. I've already made it possible for adoptables to evolve based on gender difference(for instance, Kirlia evolves into Gardevoir if its female, and Gallade if its male), and this is worth trying too. XD

Brim
11-11-2010, 04:03 PM
Great mod, thank you! ^^


Maybe I will try to change it a bit to get different eggs (like suggested here before)...we'll see XD

Plague
12-05-2010, 03:44 AM
Excellent work Arianna! Had some issues with it messing up pre-existing code, but with a few minor edits, it works flawlessly.

P.S. You're ridiculously patient dealing with so many requests of troubleshooting. Know that there are some of us who legitimately try to learn and resolve issues on our own rather than abusing your time. Some of us also understand that troubleshooting for varying code, is not an easy task.

Plague
12-06-2010, 04:26 PM
@ Arianna: Is there a simple way to modify this code so there is a waiting period after a certain creature breeds? That way users can't just breed the same ones over and over again?

Kaeliah
12-08-2010, 06:23 PM
Arianna is no longer active, Plague. There are ways of doing limits but none that I can think of are simple. :/

redheadturkey
12-08-2010, 06:31 PM
You'd want it to be pet ID specific, as opposed to just letting all female rest, etc ------------- there would be a way, I might try to code it later ^^

Plague
12-08-2010, 10:26 PM
@ Kaeliah: Sorry about that. Didn't realize she wasn't here anymore. It's sad to hear she's not active.

@ redheadturkey: Pet ID specific. Hmm. Some ideas come to mind, but I don't exactly trust the accuracy of my coding at this point. I still might dink around. If nothing else it might give others ideas and get wheels turning in a good direction.[hr]
Maybe somehow doing a modified version of the sick code, but working in time variables. Sick status seems to work the same way only instead of a happy default, the default would be an ability to breed. Instead of sick until a condition is met, unable to breed until condition is met, the condition being time span rather than click from owner. Time variable replaces owner ID and information to return to default status. I dunno. Most likely I'm on the entirely wrong track. Just throwing it out there.

Kaeliah
12-09-2010, 09:21 PM
The only way I know to do a time variable is by Cronjobs. But you could have it so a female needs so many more clicks before it can breed again. Just as an idea to throw out there.

Plague
12-10-2010, 02:54 PM
That actually sounds like a fantastic idea. It would create more variety and require the user to actively play more to try to re-breed desired creatures. Other games seem to go off the time variable, but it's like I breed all my creatures, got nothing, I'll sign on in a week when I can breed them again. And that route, for me any way, gets boring after awhile.

RoconzaArt
01-16-2011, 12:12 PM
What do I add to make it so let's say I make a cat and a dog but they can't breed with each other only there own species?

Hall of Famer
01-16-2011, 01:22 PM
I wonder how you define the pet types on your site, but you may try this. Now find the following lines:


if ($male_level < 2 OR $female_level < 2){ //this is if they can't breed
$article_content = $article_content."Sorry, one of your adoptables don't have the minimum level to breed. Keep feeding them so they can grow.";
}
Add below:


else if ($male_type != $female_type){
//this examines if they are not the same species
$article_content = $article_content."Sorry, a cat cant breed with a dog, please select again!";
}
Basically you will have to define the condition for breeding to occur. You may delete some of the lines in the else statement, since there's no need for the script to decide the species of your baby pet through random variables. You may just leave it like this too, it is not likely to cause you any fatal errors anyway. Keep in mind that you will have to modify the script significantly if you actually define cat and dog as a category, or a class/object.

Hall of Famer

RoconzaArt
01-16-2011, 03:01 PM
Thank you you HOF the code works great. I want to code away to add adoptable to a group like "dogs", "cats" and etc so that different dog breed can breed with each other but not with things like foxes or cats. To put it in a pokemon fans example like how in pokemon only pokemon in the same set groups (monster, water, fairy, etc) can breed.

I just need to do some studying.

Hall of Famer
01-16-2011, 03:07 PM
Well this is what I thought right from the beginning. To do this, you will need to create a new database column called 'group' in the table adoptable and owned_adoptables. The group can have two values, namely cat and dog. The script will check if the adoptables belong to the same species group, and execute the codes for both cases. It will require a lot more work, and you may need to modify nadopt.php and doadopt.php too.

Rozel
01-30-2011, 06:23 PM
Hi. I was wondering about some sort of limitation, and saw on the last page about having to get more clicks before you can breed again. That'd be lovely, but I don't know if that's been worked on or not at the moment XD It says that it was said back in November 2010, a little while ago, still curious if it's being worked on. Otherwise I'd like to request that. :P

Kaeliah
01-30-2011, 08:08 PM
You may want to contact Arianna and ask. :smile: I know she's working on a breeding script, but I'm not sure if it's an upgrade of this one or a completely different one.

Rozel
01-30-2011, 10:18 PM
Okay, I shall do that. 83

Hall of Famer
01-30-2011, 10:42 PM
umm I am sure Arianna is quite busy at this moment, but maybe it wont hurt to ask.

Rozel
01-31-2011, 11:23 AM
Yeah, she said she could not right now. ^^;

nobackseat
02-06-2011, 01:03 PM
I realize this is an old post, but I wanted to touch on some of the techniques here, and hope that it will help any other developers.

$article_content = $article_content."<p>Select

PHP has the capability built in to append a variable to itself, and it is much easier than reiterating the variable.

$article_content .= "<p>Select

Memory resource in this application is tremendous.

There are some simple things here that may seem insignificant, it can make a huge impact.

$femaleid = $_POST['female'];
$maleid = $_POST['male'];
$breed = $_POST['breed'];

$femaleid = secure($femaleid);
$maleid = secure($maleid);
$breed = secure($breed);

to


$femaleid = secure( $_POST[ 'female' ] );
$maleid = secure( $_POST[ 'male' ] );
$breed = secure( $_POST[ 'breed' ] );



$num = mysql_num_rows($result);

// Loop Out code < this will loop so you select all the rows and not just one
$i = 0;
while ($i < $num){


to


// Loop Out code < this will loop so you select all the rows and not just one
$i = 0;
while ( $i < mysql_num_rows( $result ) ) {
}


This is of course, only if you are using it once, and don't need the $num variable anywhere else.

And lastly,

$i++;
to
++$i;

But that is just me being extremely picky.

The reason for the above is, it is pre-incrementing and it doesn't create a memory reference.

The only difference between the two is, the last one doesn't increment until the end of the string, so in some cases it is not acceptable.

But anyways, yeah. This is not criticizing, I am just offering some tips.

NBS

Hall of Famer
02-06-2011, 01:19 PM
Well Arianna has made a new version of Breeding system in this Mys v1.2.0 we are currently developing. I dont see a need to post it atm, but you can assume this one is obsolete.

elfhome
02-08-2011, 10:19 AM
I am using this one just to give it a test and I really like it. I can't wait to see the final version in the newest release!