Mys 1.3.1 adding houses for your pets

Forum
Last Post
Threads / Messages

schepers12

Member
Premium Member
Joined
Sep 18, 2012
Messages
26
Points
0
Location
netherlands
Mysidian Dollar
5,176
[now also for 1.3.2!] adding houses for your pets

hello all,
as promised, my houses modification, still far from perfect, but it works pretty good already~

i hope you'll get the idea of how to apply/extend this mod.

i'm also glad to hear any update you've made of this~

instructions provided in the board aswell the zip file~



please don't shoot me if i did something wrong, i'm a human and i do make mistakes, so please back-up your adoptables site before you start~!
THIS IS FOR V1.3.1, for v1.3.2, see the end of this post!


(It works for me though.. :3c)


instructions below:


insert into the users table a new column:
Code:
houses int(11) default 1
___________________________________________________________________________________________

copy functions_houses into your functions folder

in the main functions file, find:
PHP:
    $GLOBALS['isloggedin'] = $isloggedin;
    $GLOBALS['username'] = $username;
    $GLOBALS['loggedinname'] = $username;
    $GLOBALS['money'] = $GLOBALS['usersettings']['money'];
    $GLOBALS['group'] = $usergroup;
and add this underneath it:
PHP:
    $GLOBALS['houses'] = $houses;
find:
PHP:
        $luid=$GLOBALS['usersettings']['uid'];
        $lsess=$GLOBALS['usersettings']['session'];
        $usergroup=$GLOBALS['usersettings']['usergroup'];
and add this line underneath them:
PHP:
        $houses=$GLOBALS['usersettings']['houses'];
___________________________________________________________________________________________
next, edit adopt.php:

include this line at the beginning:
PHP:
include("functions/functions_houses.php");
find:
PHP:
    // Begin the output of all the adoptables to the user...
    $stmt = $adopts->join("adoptables_conditions", "adoptables_conditions.id = adoptables.id")
    ->select("adoptables", array());
put this under it:
PHP:
if ($freespace > 0) {
and put before:
} // This bracket ends the else statements for whether or not an ID was entered
PHP:
this:
}}else { 
$article_content .= "You don't have enough free space in your houses left anymore, you need to buy new houses for your new adopts!";
_______________________________________________________________
breeding.php:

add:
PHP:
  include("functions/functions_houses.php");
on top

find:
PHP:
if($isloggedin == "yes" and $userstatus['canbreed'] == "yes"){
and add underneath it:
PHP:
if ($freespace > 0) {
find:
PHP:
}// this is the end of if($isloggedin == "yes")
and add this above it:
PHP:
}else { 
$article_content .= "You don't have enough free space in your houses left anymore, you need to buy new houses for your new adopts!";
}
___________________________________________________________________________________________
trade.php

add as usual in the beginning:
PHP:
include("functions/functions_houses.php");
and find:
PHP:
if($isloggedin == "yes"){
add underneath it:
PHP:
if ($freespace > 0) {
next, find:
PHP:
else{

$article_title = "Trading Not Enabled";
$article_content = "Trading is either not enabled or not currently available for your site.";


}

}

}
add this under it:
PHP:
else {
$article_content .= "You don't have enough free space in your houses left anymore, you need to buy new houses for your new adopts!";
}}
___________________________________________________________________________________________
and pound.php:

add this at the beginning:
PHP:
include("functions/functions_houses.php");
find:
PHP:
elseif($poundsettings->adopt->active == "no" and $poundsettings->system->active == "yes"){
  $article_title = "Access Denied";
  $article_content = "The admin has specified that pounded pets cannot be readopted.";
}
place above it:
PHP:
else { 
$article_content .= "You don't have enough free space in your houses left anymore, you need to buy new houses for your new adopts!"; }
}
and add after:
PHP:
  if($isloggedin == "yes" and $userstatus['canpound'] == "yes"){
this:
PHP:
if ($freespace > 0) {
____________________________
___________________________________________________________________________________________
Next, copy the houses.php file into the main directory, and make a link to it in the admin panel.




optional, you can edit functions.php again, and add this to the function getsidebar (if you haven't done so already):
before the logout.php link:
PHP:
$wpath = $GLOBALS['houses'];
$housing = $wpath;
$sidebar .= "<li><a href='houses.php'>You have {$housing} house(s)</a></li>";
optional, you can edit the variables in functions_houses.php
PHP:
($req_monforhouse, $maximumhouses, $spots)
to your desires~ :3c

This works with MYS 1.3.1


now the updated version for V1.3.2 :




simple houses system (workaround for the OOP php of mysidia, i hope this also works for people who don't know OOP php programming ;3)

edit functions_houses.php variables to your desires.

place functions_houses into your functions folder

in inc/init.php, add this just before the end:
PHP:
$function_houses = "{$dir}functions/functions_houses.php";
include($function_houses);
adopt.php:
find:
PHP:
if($canadopt == "yes"){
			//If we can adopt the adoptable, show the image and adoption link...
			$adoptform .= "<tr><td><input type='radio' name='id' id='id' value='{$row->id}' /></td><td style='text-align: center'><img src='{$row->eggimage}' /></td>
			               <td><strong>{$row->type}</strong><br />{$row->description}</td></tr>";
	  }
replace by:
PHP:
if($canadopt == "yes"){
	  if ($freespace > 0) {  
			//If we can adopt the adoptable, show the image and adoption link...
			$adoptform .= "<tr><td><input type='radio' name='id' id='id' value='{$row->id}' /></td><td style='text-align: center'><img src='{$row->eggimage}' /></td>
			               <td><strong>{$row->type}</strong><br />{$row->description}</td></tr>";
	  } else {
	     $mysidia->page->addcontent($houseserror);
	  }
	  }
breeding.php

find:
PHP:
 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);	

       // Get other related information	   
       $code = codegen(10, 0);
	   $alts = getaltstatus($female_species->id, 0, 0);
       $time = time();
	   
	   // Insert a baby adoptable to the database
	   $mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $types[$typerand], "name" => $types[$typerand], "owner" => $mysidia->user->username, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, 
			                                          "imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $genders[$genderrand], "lastbred" => 0));
	   $congrats = 	"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>";
       $mysidia->page->addcontent($congrats, TRUE);					
	   $mysidia->db->update("owned_adoptables", array("lastbred" => $time), "aid = '{$mysidia->input->post("female")}'");
	   $mysidia->db->update("owned_adoptables", array("lastbred" => $time), "aid = '{$mysidia->input->post("male")}'");	   
   }
replace by:
PHP:
   else{
   
	  if ($freespace > 0) { 
	   // 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);	

       // Get other related information	   
       $code = codegen(10, 0);
	   $alts = getaltstatus($female_species->id, 0, 0);
       $time = time();
	   
	   // Insert a baby adoptable to the database
	   $mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $types[$typerand], "name" => $types[$typerand], "owner" => $mysidia->user->username, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, 
			                                          "imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $genders[$genderrand], "lastbred" => 0));
	   $congrats = 	"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>";
       $mysidia->page->addcontent($congrats, TRUE);					
	   $mysidia->db->update("owned_adoptables", array("lastbred" => $time), "aid = '{$mysidia->input->post("female")}'");
	   $mysidia->db->update("owned_adoptables", array("lastbred" => $time), "aid = '{$mysidia->input->post("male")}'");	   
	   } else {
	   	     $mysidia->page->addcontent($houseserror);
	   }
   }
doadopt.php:

find:
PHP:
      $canadopt = canadopt($row->id, "adopting", "none", $row);
	  if($canadopt == "yes"){
	     $name = (!$mysidia->input->post("name"))?$row->type:$mysidia->input->post("name");
		 $alts = getaltstatus($row->id, 0, 0);
		 $code = codegen(10, 0);
		 $genders = array('f', 'm');
		 $rand = rand(0,1);
         $mysidia->user->changecash(-$row->cost);
		 $mysidia->page->settitle("{$name} adopted successfully");
		 $mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $row->type, "name" => $name, "owner" => $mysidia->user->username, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, 
			                                            "imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $genders[$rand], "lastbred" => 0));
		 $aid = $mysidia->db->select("owned_adoptables", array("aid"), "code='{$code}' and owner='{$mysidia->user->username}'")->fetchColumn();
         $message = "<img src='{$row->eggimage}'><br>Congratulations!  You just adopted {$name}.  You can now manage {$name} on the 
					 <a href='myadopts.php'>My Adopts</a> page.<br><br><b><a href='myadopts.php?act=manage&id={$aid}'>Click Here to Manage {$name}</a><br>
					 <a href='myadopts.php?action=bbcode&id={$aid}'>Click Here to get BBCodes / HTML Codes for {$name}</a></b><br><br>
					 Be sure and <a href='levelup.php?id={$aid}'>feed</a> {$name} with clicks so that they grow!";
         $mysidia->page->addcontent($message);
		 $mysidia->session->terminate("adopt");
	  }
	  else $mysidia->displayerror("action");
replace by:
PHP:
	  if ($freespace > 0) { 
      $canadopt = canadopt($row->id, "adopting", "none", $row);
	  if($canadopt == "yes"){
	     $name = (!$mysidia->input->post("name"))?$row->type:$mysidia->input->post("name");
		 $alts = getaltstatus($row->id, 0, 0);
		 $code = codegen(10, 0);
		 $genders = array('f', 'm');
		 $rand = rand(0,1);
         $mysidia->user->changecash(-$row->cost);
		 $mysidia->page->settitle("{$name} adopted successfully");
		 $mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $row->type, "name" => $name, "owner" => $mysidia->user->username, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, 
			                                            "imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $genders[$rand], "lastbred" => 0));
		 $aid = $mysidia->db->select("owned_adoptables", array("aid"), "code='{$code}' and owner='{$mysidia->user->username}'")->fetchColumn();
         $message = "<img src='{$row->eggimage}'><br>Congratulations!  You just adopted {$name}.  You can now manage {$name} on the 
					 <a href='myadopts.php'>My Adopts</a> page.<br><br><b><a href='myadopts.php?act=manage&id={$aid}'>Click Here to Manage {$name}</a><br>
					 <a href='myadopts.php?action=bbcode&id={$aid}'>Click Here to get BBCodes / HTML Codes for {$name}</a></b><br><br>
					 Be sure and <a href='levelup.php?id={$aid}'>feed</a> {$name} with clicks so that they grow!";
         $mysidia->page->addcontent($message);
		 $mysidia->session->terminate("adopt");
	  }
	  else $mysidia->displayerror("action");
	  }else {
	  	     $mysidia->page->addcontent($houseserror);
	  }
trade.php:

find:
PHP:
   // At the very last, evaluate if the user can afford this transaction
   if($mysidia->settings->cashenabled){
      $moneyleft = $mysidia->user->getcash() - $mysidia->input->post("cashgiven");
	  if($moneyleft < 0){
	     $error++;
	     $mysidia->page->addcontent($lang->cash);
	  }	  
   }

replace by:
PHP:
	  if ($freespace > 0) { 
   // At the very last, evaluate if the user can afford this transaction
   if($mysidia->settings->cashenabled){
      $moneyleft = $mysidia->user->getcash() - $mysidia->input->post("cashgiven");
	  if($moneyleft < 0){
	     $error++;
	     $mysidia->page->addcontent($lang->cash);
	  }	  
   }
   	  }else {
	  	     $mysidia->page->addcontent($houseserror);
			 $error++;
	  }
pound.php:

find:
PHP:
   else{
      // An id has been entered, let's process the request
	  $poundadopt = new Pound($mysidia->input->post("aid"), "adopt");
	  if(!$poundadopt->validate()) $mysidia->page->settitle($lang->global_error);
	  else{
	     // Validation completed, yay!
	     $mysidia->page->settitle($lang->global_action_complete);
		 $poundadopt->doadopt();
	  }	 
   }
replace by:
PHP:
   else{
	  if ($freespace > 0) { 
      // An id has been entered, let's process the request
	  $poundadopt = new Pound($mysidia->input->post("aid"), "adopt");
	  if(!$poundadopt->validate()) $mysidia->page->settitle($lang->global_error);
	  else{
	     // Validation completed, yay!
	     $mysidia->page->settitle($lang->global_action_complete);
		 $poundadopt->doadopt();
	  }	
	  } else{
	     // Validation completed, yay!
	     $mysidia->page->settitle($lang->global_action_complete);
		 $poundadopt->doadopt();
	  }	
   }

last: copy houses.php into your main adopts folder, and add a link to it.
 

Attachments

  • house add.zip
    6.1 KB · Views: 12
  • house v132.zip
    3.7 KB · Views: 11
Last edited:
Well its similar to the concept of Pokebox, which acts as container for adoptables and can only hold a certain number of them. If you want to adopt more, you will have to switch to buy a new house.
 
@silver kistune: yes, my site is running all my mods (running v1.3.1): touhoupets.com :)

edit: i can't get to know how to make this for v1.3.2, so i won't update this script until i know how to do it.. :/ EDIT: made a workaround for it, see start post!
 
Last edited:
Oh great, you made the script compatible with Mys v1.3.2 now. Actually its not that complex at all, just a change in the database query and text/article output syntax. The ACP change is much more dramatic though.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,274
Messages
33,115
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top