![]() |
Breeding
Yes, I know that this will take a lot of work and I'm certainly not the right person to be doing this, given my knowledge of PHP.
Is anyone here making a script right now, or would anyonee like to give me some help on my current page (which is very drafty and probably not the right way to code it)? Here's my current code, if anyone would like to look and help me. Most of the things which I need help on are in comments, where I have no idea what to do. PHP Code:
Arianna |
RE: Breeding
What I would recommend is that you use the alternate images system as a basis for gendering your adoptables. Make each adoptable have a 1 in 2 chance of using the alternate images. Then when you make new adoptables always use alternate images and make the primary images female and the alternates male. That way then you have a 50/50 shot of getting a male or female adoptable.
Then for breeding, simply check if the adoptable is using the primary or alternate images. So, for sample breeding what you could do is check if the user has one adoptable of type x that is male and one of type x that is female. If they do, then they are allowed to breed. :) Hope it helps, Brandon |
RE: Breeding
Hmm, that makes sense. However, I already made the whole gender system and I quite like it. :/ We have alt images which are different things (not female/male) so I don't think that that would work.
Is there any way that this script would ever work, or would it make sense to scrap it? |
RE: Breeding
I would do like that: create a table to store adoptables that users want do breed
then create a page so users can put the adoptables there, like a 'daycare', and while they are there, they are removed from the owned_adoptables then a page that displays the adoptables in the daycare, and allows users to choose if there's any that they want to breed with, and when they choose, the other adoptable go to the daycare table too, and also the date is inserted, so you can put something that allows the user to return and see if they bred well just after some days and I guess each user has to keep one egg.. idk just some ideas '-' |
RE: Breeding
I was thinking more of an instant system. I don't really know what to do. Do you think that your way would make it harder or easier for a PHP novice like me to complete?
Does anyone have any advice on the pieces of code I'm missing? |
RE: Breeding
that way would be harder I guess '-' but I don't understand very well what you're trying to do x_x
is it like, just breeding two of your adoptables into one new? I'm a PHP novice too like you, but I'll see your code e_e $aid=@mysql_result($result,$i,"id"); //The adoptable's ID $type=@mysql_result($result,$i,"type"); $description=@mysql_result($result,$i,"description "); $gender=@mysql_result($result,$i,"gender"); $eggimage=@mysql_result($result,$i,"eggimage"); $query = "SELECT * FROM ".$prefix."owned_adoptables WHERE level='2' AND owner='$loggedinname'"; //is this how we select it, somehow? for this part... you have to estabilish a $result variable first, and the $query is not being used at all.. also, the 'level' is not a colum in owned_adoptables.. do you want to select the rows just from the adoptables that are level 2? well I'll guess you forgot an important thing.. how the user will select the adoptables that he wants to breed? .-. I'll try to create a code to that and I'll post here but I'm not sure I can haha x_x |
RE: Breeding
Basically what I want is that the user selects adoptable 'a' which is a female, and then it displays all males. They then choose the male. This sets adoptable a's id to parent1 and adoptable b's id to parent2. This then determines how the egg with be.
I'm a PHP beginner would be better to describe it. The only thing I've learnt from is this script. -.- Yes, I'd like to select the ones which are level 2 (grown ups). Good luck with the code! I'm sorry I had no idea, what to do there. xP |
RE: Breeding
i've been on the verge of finishing my breeding script but i had homework, i started like 2 weeks ago
|
RE: Breeding
Awesome!
Is there any chance that I could use it or something like that? I'd really love to be able to use it. Do you use something like genders on your script, or do you use alt images? |
RE: Breeding
ok, I did it... I did not test it, because my gender system is a little different, but I'll test soon.
I'm not sure it'll work, but I tried to explain everything for you, so you can change what is necessary If it works, or if you change it so it works, you can release it in mods forum :D PHP Code:
|
RE: Breeding
Awesome! I have to go now, but I'll test it tomorrow (on my test site).
|
RE: Breeding
After a few edits (some brackets didn't match) I managed to get it to show, however, it only shows the females on the drop down lists, not the males (the second list is blank.)
Is it possible at $result2/$num2/$i2 are not valid variables? |
RE: Breeding
Something amazing - my dad (he knows C and C++ and stuff like that) helped me and I managed to have the whole code working!
PHP Code:
|
RE: Breeding
Don't forget to secure your variables. Anything coming in from the user needs to be secured, otherwise your site can easily be hacked.
For: PHP Code:
PHP Code:
|
RE: Breeding
Okay, I'll change that.
Have you any ideas on how to get it working so it inserts the adoptable properly? |
RE: Breeding
Make sure that the number of columns in this line:
PHP Code:
|
RE: Breeding
Okay, let me see
PHP Code:
aid, type, name, owner, currentlevel, totalclicks, code, imageurl, usealternates, tradestatus, isfrozen, gender... date. I cannot see how I missed that. xP I'll edit and see if it works.[hr] I now did that, but it tells me this at the top of the page (it still displays the rest, though). Code:
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 4 on MySQL result index 22 in /home/pixelpup/public_html/twig3/adoptables/breeding.php on line 76 |
RE: Breeding
Here is my updated version. I'm doing OK - the code is free of syntax errors and it defines the variables correctly, but it won't insert into the table at all!
If anyone is nice enough to help, it is supposed to insert the adoptable on line 195. PHP Code:
|
RE: Breeding
you use $name = $new_name; But just looking over it quickly I don't see where $new_name is defined.
Sea |
RE: Breeding
Here :D
PHP Code:
Code:
Manage Ik & Random's Daughter now! It's type is Jinx and it was born on October 27th, 2009! You can change its name to your liking. |
RE: Breeding
Quote:
Actually I believe that that is your problem. using that in the insert would cause many issues. basically you are trying to insert PHP Code:
Sea |
RE: Breeding
Gosh, thanks so much! I'll go and edit that. :D[hr]
I'm ecstatic that it basically works now! Thanks so much, Sea! I'm having one (hopefully last) problem. If some adoptables have been removed, I get this kind of message at the top of the page: Code:
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 2 on MySQL result index 20 in /home/pixelpup/public_html/twig3/adoptables/breeding.php on line 104 EDIT: I managed to disable it by putting an @ in front of the function. :D Now off to work on the fact that the gender is set once and stays the same (forgot to copy over my edited gender mod. xP) |
RE: Breeding
Before I go to bed - there are 2 problems. I'd love if anyone could have any advice on these.
Firstly, the type selector thing doesn't work. It's always the the same type, no matter what. xP Secondly, they are always the same gender. Maybe it is somehow not clearing the variable? Thanks so much. :D |
RE: Breeding
Is anyone able to help?
|
RE: Breeding
I have a new, updated version of the code.
It creates the adoptable just fine, even if it's different types which are breeding. However, the gender is always female, which is getting on my nerves. Also, when it gives you a list of female and male adoptables, they are always the same length, even if there is one male and 8 females, there are 8 select boxes, 7 of them which only contain '()' in them. Is there a way to solve this? **code taken out as there is an updated version.** |
RE: Breeding
Can you please post the SQL of your owned_adoptables table as well so I can take a look at the data you are working with? You can post just about 10 lines if the whole thing is long.
|
RE: Breeding
I actually managed to get further - I was using '=' instead of '==', silly me!
Now it has the problem where there are two drop-down lists, and they are always the same length. If there are 10 females and 2 males, there are 10 'boxes' for males, though only two are occupied - the others only have '()' in them. xP How do I get rid of this? When I'm done with that, the whole thing will be done! :D The whole thing is this: PHP Code:
PHP Code:
Nevermind, it was a stupid mistake.. The feature is finished now![hr] It's working perfectly now, except for a really weird sort order. Somehow, it seems to enter it right after one of their parents, irregardless of the $aid variable. xP |
RE: Breeding
Is there any way to get the code to insert it after the last value in the table?
|
All times are GMT -5. The time now is 08:16 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.