Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 10-29-2012, 10:19 AM
Hedgen's Avatar
Hedgen Hedgen is offline
Member
 
Join Date: Oct 2012
Posts: 36
Gender: Male
Credits: 4,805
Hedgen is on a distinguished road
Default Gender Questions [Solved]

  Spoiler: No need for this now. 
1: How can I make an item that switches the adoptable's gender?



Edit: Figured this one out:
2: If the first one is more challenging to do, How can I disable adoptables from becoming males on adopt? I have a site where all the adoptables are female (its an adoptable site based on the game series Touhou, which have almost all female characters) and I want to make it so Female is the only gender they can get when you adopt them/use a promo code to get them.


Edit: Figured this one out also.
3: How can I enable same sex breeding?

Last edited by Hedgen; 10-30-2012 at 01:57 AM.
Reply With Quote
  #2  
Old 10-30-2012, 12:06 AM
Hedgen's Avatar
Hedgen Hedgen is offline
Member
 
Join Date: Oct 2012
Posts: 36
Gender: Male
Credits: 4,805
Hedgen is on a distinguished road
Default

I have taken a look at the doadopt.php code and the breeding.php code, and figured out how to change it so that you select 2 females, and also only females will be adopted, but when I tested the breeding I was banned. How do I make it so my users and I don't get banned? (I put the code back to the original ('f', 'm') array on doadopt.php and fixed the breeding.php page for now.

Edit: I figured out the banning thing, now I just need to figure out how to check to see if dropdown2 = dropdown1

Edit2: I figured out how to get everything working :) I made the check be:
Code:
elseif ($female->aid == $male->aid) { //Yes I know it says male, I don't want to end up screwing up the whole code changing all the "males" to "female2"
        $article_content .= "Sorry, you can not breed the same adoptable with itself.";
        }
and that worked fine for the checking. I also changed later so that instead of being a chance of being 'f','m' I just changed it to be 'f','f'
__________________
I have some small tutorials Here that show things such as re-arranging the SIDEFEED and LINKSBAR, and redirecting people after login.

Last edited by Hedgen; 10-30-2012 at 01:52 AM.
Reply With Quote
  #3  
Old 10-30-2012, 02:49 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: 327,935
Hall of Famer is on a distinguished road
Default

umm I was wondering how you modified your code tbh. If you are adding new item functions, its a good practice to add new functionalities in its corresponding function file rather than edit the main script files such as inventory.php.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #4  
Old 10-30-2012, 07:13 AM
Hedgen's Avatar
Hedgen Hedgen is offline
Member
 
Join Date: Oct 2012
Posts: 36
Gender: Male
Credits: 4,805
Hedgen is on a distinguished road
Default

Quote:
Originally Posted by Hall of Famer View Post
umm I was wondering how you modified your code tbh. If you are adding new item functions, its a good practice to add new functionalities in its corresponding function file rather than edit the main script files such as inventory.php.
I decided to just modify breeding.php since that seemed easier for me than figuring out how to make a new item function ^^' I don't really have any php knowledge but I do have basic programming college. (in college with software design as major)

The modified code for breeding.php:

Code:
<?php

include("functions/functions.php");
include("functions/functions_users.php");
include("functions/functions_adopts.php");
include("inc/lang.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'];
$userstatus = getuserstatus($loggedinname);
//$idfemale1;
//$idfemale2;

if($isloggedin == "yes" and $userstatus['canbreed'] == "yes"){
    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
        $stmt = $adopts->select("owned_adoptables", array(), "owner = '{$loggedinname}' AND gender = 'f' AND currentlevel >= {$breedinglevel} AND lastbred <= '{$lastweek}'");
        $row = $stmt->fetchObject();
		if(is_object($row)){
            //Fetch the first row...
			$article_content .= "<p>Female: <select name='female'>
            <option value='{$row->aid}'>{$row->name} ({$row->type})</option>";
		$idfemale1 = $row->aid;
            // Continue to fetch more rows...
			while ($row = $stmt->fetchObject()) {
				$article_content .= "<option value='{$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
		$stmt = $adopts->select("owned_adoptables", array(), "owner = '{$loggedinname}' AND gender = 'f' AND currentlevel >= {$breedinglevel} AND lastbred <= '{$lastweek}'");
        $row = $stmt->fetchObject();
		if (is_object($row)) {
			$article_content .= "<p>Female: <select name='male'>
                                 <option value='{$row->aid}'>{$row->name} ({$row->type})</option>";
			while ($row = $stmt->fetchObject()) {
				$article_content .= "<option value='{$row->aid}'>{$row->name} ({$row->type})</option>";
				//$idfemale2 = $row->aid;
			}
			$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 {
		$female = $adopts->select("owned_adoptables", array(), "aid = '{$femaleid}'")->fetchObject();	
		$female_species = $adopts->select("adoptables", array(), "type = '{$female->type}'")->fetchObject();	
        $female_class = explode(",",$female_species->class);
		
		$male = $adopts->select("owned_adoptables", array(), "aid = '{$maleid}'")->fetchObject();	
		$male_species = $adopts->select("adoptables", array(), "type = '{$male->type}'")->fetchObject();
        $male_class = explode(",",$male_species->class);

		// let's check the requirements first.
        if(classcheck($female_class, $male_class) == "no"){//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.";
        }
        elseif(($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.";    
        } elseif ($female->aid == $male->aid) { //new
        $article_content .= "Sorry, you can not breed the same adoptable with itself.";
        }//end new
       // elseif($female->owner != $loggedinname or $male->owner != $loggedinname){ //commented these out so I wouldn't accidentally ban myself again
           // 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
          // $ban = banuser($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
          // $ban = banuser($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','f');
			$genderrand = rand(0,1);				
            $code = codegen(10, 0);

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

			$time = time();
	        $adopts->insert("owned_adoptables", array("aid" => NULL, "type" => $types[$typerand], "name" => $types[$typerand], "owner" => $loggedinname, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, 
			                "imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $genders[$genderrand], "lastbred" => 0));
						
			$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>";

			$adopts->update("owned_adoptables", array("lastbred" => $time), "aid = '{$femaleid}'");
			$adopts->update("owned_adoptables", array("lastbred" => $time), "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")
elseif($isloggedin == "yes" and $userstatus['canbreed'] == "no"){
    $article_content .= "It appears that you have been banned from breeding your adoptables. Please contact an administrator for assistance.";   
}
else {
    $article_content .= "You are not logged in. Please log in to use this feature.";
}

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

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

?>

I will probaby modify the ban that talks about modifying the code to try breeding adoptables that aren't yours, and modify it into not banning but having a message "Big brother is now watching you for trying to breed adoptables that aren't yours"
__________________
I have some small tutorials Here that show things such as re-arranging the SIDEFEED and LINKSBAR, and redirecting people after login.
Reply With Quote
  #5  
Old 10-30-2012, 07:27 AM
draugluin's Avatar
draugluin draugluin is offline
Member
 
Join Date: Oct 2011
Location: germany
Posts: 120
Gender: Unknown/Other
Credits: 10,753
draugluin is on a distinguished road
Default

Quote:
How can I make an item that switches the adoptable's gender?
its a very interesting question. I've tried a item, which makes an adoptable male, but

PHP Code:
function items_male($item$adopt){
  
// Update the gender info.
  
$GLOBALS['adopts']->update("owned_adoptables", array("gender" => 'm'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");    
  
$note "Its male now<br>";
  
//Update item quantity...
  
$delitem $item->removeitem(1$item->owner);  
  return 
$note;

does'nt work. I've copied it from "breed1" which changes the "lastbred to 0" modified to "gender = m"

where is the fault???
Reply With Quote
  #6  
Old 10-30-2012, 07:45 AM
Hedgen's Avatar
Hedgen Hedgen is offline
Member
 
Join Date: Oct 2012
Posts: 36
Gender: Male
Credits: 4,805
Hedgen is on a distinguished road
Default

Quote:
Originally Posted by draugluin View Post
its a very interesting question. I've tried a item, which makes an adoptable male, but

PHP Code:
function items_male($item$adopt){
  
// Update the gender info.
  
$GLOBALS['adopts']->update("owned_adoptables", array("gender" => 'm'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");    
  
$note "Its male now<br>";
  
//Update item quantity...
  
$delitem $item->removeitem(1$item->owner);  
  return 
$note;

does'nt work. I've copied it from "breed1" which changes the "lastbred to 0" modified to "gender = m"

where is the fault???
I'll look into it a little when I get to school, have to leave in 20 minutes and need to get Math done I was suppose to last night ^^'

Unless of course you figure it out first :)

Edit: I have been messing with the code a bit and I can't seem to get it to work :( Sorry
__________________
I have some small tutorials Here that show things such as re-arranging the SIDEFEED and LINKSBAR, and redirecting people after login.

Last edited by Hedgen; 10-30-2012 at 10:42 AM.
Reply With Quote
  #7  
Old 10-30-2012, 11:12 AM
draugluin's Avatar
draugluin draugluin is offline
Member
 
Join Date: Oct 2011
Location: germany
Posts: 120
Gender: Unknown/Other
Credits: 10,753
draugluin is on a distinguished road
Default

okay, I fixed it

this is the code for useful gender-swap

PHP Code:
function items_alts1($item$adopt){
  
// First lets check if alternative image exists for an adoptable at this level.
  
$lev $GLOBALS['adopts']->select("levels", array(), "adoptiename='{$adopt->type}' and thisislevel ='{$adopt->currentlevel}'")->fetchObject();
  if(
$lev->alternateimage == ""){
      
// The alternate image does not exist, cannot convert adoptable into its alternate form
    
$note "It appears that your adoptable could not swap its gender...<br>";
  }
  else{
      
// The alternate image exists, conversion between primary and alternate image is possible.
    
switch($adopt->usealternates){
      case 
"yes"
        
$GLOBALS['adopts']->update("owned_adoptables", array("usealternates" => 'no'"gender" => 'm'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");        
        
$note "{$adopt->name} is male.";
        break;
      default:
        
$GLOBALS['adopts']->update("owned_adoptables", array("usealternates" => 'yes'"gender" => 'f'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");       
        
$note "  {$adopt->name} is female";
    }
      
//Update item quantity...
      
$delitem $item->removeitem(1$item->owner);    
  }
  return 
$note;    

You only have to modify your text and have alternate images female.
I've the primary image for male and alternates for female.

much fun - I will have fun too - or better : my user
Reply With Quote
  #8  
Old 10-30-2012, 11:23 AM
Hedgen's Avatar
Hedgen Hedgen is offline
Member
 
Join Date: Oct 2012
Posts: 36
Gender: Male
Credits: 4,805
Hedgen is on a distinguished road
Default

Quote:
Originally Posted by draugluin View Post
okay, I fixed it

this is the code for useful gender-swap

PHP Code:
function items_alts1($item$adopt){
  
// First lets check if alternative image exists for an adoptable at this level.
  
$lev $GLOBALS['adopts']->select("levels", array(), "adoptiename='{$adopt->type}' and thisislevel ='{$adopt->currentlevel}'")->fetchObject();
  if(
$lev->alternateimage == ""){
      
// The alternate image does not exist, cannot convert adoptable into its alternate form
    
$note "It appears that your adoptable could not swap its gender...<br>";
  }
  else{
      
// The alternate image exists, conversion between primary and alternate image is possible.
    
switch($adopt->usealternates){
      case 
"yes"
        
$GLOBALS['adopts']->update("owned_adoptables", array("usealternates" => 'no'"gender" => 'm'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");        
        
$note "{$adopt->name} is male.";
        break;
      default:
        
$GLOBALS['adopts']->update("owned_adoptables", array("usealternates" => 'yes'"gender" => 'f'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");       
        
$note "  {$adopt->name} is female";
    }
      
//Update item quantity...
      
$delitem $item->removeitem(1$item->owner);    
  }
  return 
$note;    

You only have to modify your text and have alternate images female.
I've the primary image for male and alternates for female.

much fun - I will have fun too - or better : my user
That actually gives me an idea (more work for the artist I find to do art for the site also XD)
basically male and female versions of my adoptables, and certain adoptables that have normal alt images I can just add a check in that code so that if used on certain characters it doesn't allow you to gender swap xD. (for characters that must be female, and/or characters that have alternate forms, like one of my adoptables will have an alt form of a chimera. )

Anyways, thanks for the code! I probably never would have been able to write that xD (well I probably would if I knew more PHP xD)
__________________
I have some small tutorials Here that show things such as re-arranging the SIDEFEED and LINKSBAR, and redirecting people after login.

Last edited by Hedgen; 10-30-2012 at 11:41 AM.
Reply With Quote
  #9  
Old 10-30-2012, 07:22 PM
Aasixx's Avatar
Aasixx Aasixx is offline
.. your friendly geek. c:
 
Join Date: Nov 2011
Location: somewhere ur not.
Posts: 191
Gender: Female
Credits: 27,195
Aasixx is on a distinguished road
Default

I tried your code, draugluin and I got this: "Fatal error: Cannot redeclare items_alts1() (previously declared in /home/albisi9/public_html/functions/functions_items.php:179) in /home/albisi9/public_html/functions/functions_items.php on line 206"

I don't think it will allow you to call the new function "alts2" because when I change it to something different, it goes back to normal. :|
__________________
Reply With Quote
  #10  
Old 10-31-2012, 08:34 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: 327,935
Hall of Famer is on a distinguished road
Default

Well there is a duplicate function called items_alts1 in your script file, so apparently it aint gonna work. You'd have to comment out that function, replace it, or change the name to items_alt2.
__________________


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

Thread Tools
Display Modes

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 03:34 PM
Gender superdude44 Questions and Supports 5 07-11-2013 01:17 AM
different images for gender MA 1.3.3 draugluin Questions and Supports 3 06-18-2013 01:30 AM
Mys v1.3.2 Gender Ratio Mod for Mys v1.3.2 Hall of Famer Mys v1.3.x Mods 6 01-08-2013 02:02 PM
Gender? [answered] Arianna Questions and Supports 4 11-19-2009 06:33 AM


All times are GMT -5. The time now is 10:51 AM.

Currently Active Users: 666 (0 members and 666 guests)
Threads: 4,080, Posts: 32,024, 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