breeding enable alt problem

Forum
Last Post
Threads / Messages

SilverDragonTears

I am your Nemesis.
Premium Member
Joined
Jun 1, 2011
Messages
1,113
Points
36
Mysidian Dollar
51,802
When a member breeds their adopt and they get a female, it should insert yes for usealternates. It doesn't though... It assumes it's male and inserts no

breeding.php
PHP:
<?php

include("inc/functions.php");

//***************//
//  START SCRIPT //
//***************//

$breedinglevel = grabanysetting('breedinglevel');

$article_title = "Breeding System"; 
$article_content = "<p>You may breed your adoptables here. They must be at least a level {$breedinglevel} to be able to breed.</p>"; 

$femaleid = $_POST['female'];
$maleid = $_POST['male'];
$breed = $_POST['breed'];
$date = date("M j, Y");
// $date = "March 23, 2010";

if ($isloggedin == "yes"){

$query = "SELECT * FROM ".$prefix."owned_adoptables WHERE owner='".$loggedinname."' AND currentlevel<='3' AND isfrozen='no'";
$result = mysql_query($query);
$num = mysql_num_rows($result);

if($num >= 5){
$breed = 'no';
$article_title = "Too many eggs to breed!";
$article_content = "You already have too many eggs to take care of!";
}
   else if ($breed != 'yes'){ // if they have not chosen which pets to breed yet, we let them choose
        $article_content .= "<p>Select the two adoptables that you'd like to breed:</p><form method='post'>"; 
        $lastweek = time() - ((grabanysetting('breedinginterval')) * 24 * 60 * 60);
        
        // show all available female adoptables
        $result = runquery("SELECT * FROM ".$prefix."owned_adoptables WHERE owner = '$loggedinname' AND gender = 'f' AND currentlevel >= {$breedinglevel} AND lastbred <= '$lastweek'") ;
        $num = mysql_num_rows($result);
        if ($num!=0) {
            $article_content .= "<p>Female: <select name='female'>";
            while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                $article_content .= "<option value='{$row['aid']}'>{$row['aid']} {$row['name']} ({$row['type']})</option>";
            }
            $article_content .= "</select></p>";
        }
        else {
            $article_content .= "<p>None of your female adoptables can breed at the time.</p>";
        }
        
        // show all available male adoptables
  
        $result = runquery("SELECT * FROM ".$prefix."owned_adoptables WHERE owner = '$loggedinname' AND gender = 'm' AND currentlevel >= {$breedinglevel} AND lastbred <= '$lastweek'") ;
      $num = mysql_num_rows($result);

            if ($num!=0) {
            $article_content .= "<p>Male: <select name='male'>";
            while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                $article_content .= "<option value='{$row['aid']}'>{$row['aid']} {$row['name']} ({$row['type']})</option>";
            }

            $article_content .= "</select></p>";
        }
        else {
            $article_content .= "<p>None of your male adoptables can breed at the time.</p>";
        }
        $article_content .= "<input type='hidden' name='breed' value='yes'><input type='submit' value='Breed It'></form>";
    } 
    else {
        $result = runquery("SELECT * FROM ".$prefix."owned_adoptables WHERE aid = '$femaleid'") ;
        $female = mysql_fetch_array($result);

        $female_type = @mysql_result($result,0,'type'); 
        $female_name = @mysql_result($result,0,'name');

        $result2 = runquery("SELECT * FROM ".$prefix."adoptables WHERE type = '$female_type'") ;
        $female_species = mysql_fetch_array($result2);
        $female_class = @mysql_result($result2,0,'class');
                $bredchance = @mysql_result($result2,0,'bredchance'); 
        
        $result = runquery("SELECT * FROM ".$prefix."owned_adoptables WHERE aid = '$maleid'") ;
        $male = mysql_fetch_array($result);

        $male_type = @mysql_result($result,0,'type'); 
        $male_name = @mysql_result($result,0,'name');

        $result2 = runquery("SELECT * FROM ".$prefix."adoptables WHERE type = '$male_type'") ;
        $male_species = mysql_fetch_array($result2);
        $male_class = @mysql_result($result2,0,'class'); 


        // let's check the requirements first.
        if($female_class != $male_class){//check if the male and female belong to the same breeding class
            $article_content = "Sorry, it seems that your two adoptables do not belong to the same breeding class.";
        }
        else if (($female['currentlevel'] < (grabanysetting('breedinglevel'))) OR ($male['currentlevel'] < (grabanysetting('breedinglevel')))){ // check the adoptables' levels
            $article_content .= "Sorry, one of your adoptables don't have the minimum level to breed. Keep getting clicks for them so they can grow.";    
        } 

        // the below codes check if the user has modified the form using firebug or inspect element...
        elseif($female['owner'] != $loggedinname or $male['owner'] != $loggedinname){
           // The adoptables do not belong to the owner... This user has apparently modified the content of drop-down form, and thus deserves his/her punishment
           runquery("UPDATE {$prefix}users SET usergroup=5 WHERE username='{$loggedinname}'");
           $article_title = "An error has occurred";    
           $article_content = "It appears that at least one of the adoptables selected do not belong to yours. You have been banned for this action, please contact site administrator for more info.";
        }
        elseif($female['gender'] != "f" or $male['gender'] != "m"){
           // The female's gender is male or male's gender is female? This user has apparently modified the content of drop-down form, and thus deserves his/her punishment
           runquery("UPDATE {$prefix}users SET usergroup=5 WHERE username='{$loggedinname}'");
           $article_title = "An error has occurred";    
           $article_content = "It appears that the female and/or male adoptables gender's have been modified. You have been banned for this action, please contact site administrator for more info.";              
        }
        else {
            // we choose the type!
            $types = array($female_type, $male_type);
            $typerand = rand(0,1);        
            
            // we choose the gender
            $genders = array('f', 'm');
            $genderrand = rand(0,1);                
                  $code = rand(1, 20000); 

            // MESSY - I'm blanking out on how to find the actual alt status stuff right now, any help would be lovely.
            $alts = getaltstatus($aid, 0, 0);

            $time = time();

            $bredtemp = rand(0,99);
if($bredtemp >= $bredchance){
$article_content = "How unfortunate, your adoptables have failed at breeding T_T. You will have to wait a few days and give a try again...";    
}    
else{
$newquery = "INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$types[$typerand]', 'Unnamed', '$loggedinname', '0', '0', '$code', '', '$alts', 'notfortrade', 'no', '$genders[$genderrand]', '$lastbred', '$lastinfluence', 'sort', '$maleid', '$femaleid', '$desc', '$date', '$time', '')";
            runquery($newquery);
            $article_content = "Congratulations! Breeding is successful,  you have acquired a baby ".$types[$typerand]." from breeding center.
            <br><a href='myadopts.php'>Manage your new {$types[$typerand]} now!</a></p>";
}            

            runquery("UPDATE ".$prefix."owned_adoptables SET lastbred = '$time' WHERE aid = '$femaleid'");
            runquery("UPDATE ".$prefix."owned_adoptables SET lastbred = '$time' WHERE aid = '$maleid'");
        
        } // 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 {
    $article_content .= "You are not logged in. Please log in to use this feature.";
}

//***************//
//  OUTPUT PAGE  //
//***************//

echo showpage($article_title, $article_content, $date);

?>
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,122
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top