PDA

View Full Version : Mys 1.3.1 adding houses for your pets


schepers12
11-14-2012, 01:24 PM
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: houses int(11) default 1_________________________________________________ __________________________________________

copy functions_houses into your functions folder

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

include this line at the beginning:
include("functions/functions_houses.php");find:
// 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:
if ($freespace > 0) {
and put before:
} // This bracket ends the else statements for whether or not an ID was entered

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:
include("functions/functions_houses.php");
on top

find:
if($isloggedin == "yes" and $userstatus['canbreed'] == "yes"){
and add underneath it:
if ($freespace > 0) {
find:

}// this is the end of if($isloggedin == "yes")
and add this above it:
}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:

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

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


}

}

}
add this under it:
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:

include("functions/functions_houses.php");
find:

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:
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:
if($isloggedin == "yes" and $userstatus['canpound'] == "yes"){ this:
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:

$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 ($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:

$function_houses = "{$dir}functions/functions_houses.php";
include($function_houses);

adopt.php:
find:

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:
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:
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:

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:

$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:
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:
// 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:

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:

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:

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.

Corsair
11-28-2012, 08:42 PM
Houses? I'm not sure what that means.

Hall of Famer
11-29-2012, 05:10 AM
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.

SilverDragonTears
12-08-2012, 07:09 PM
This is interesting. Anyone have a working site with this on it?

LucasA33
12-09-2012, 10:48 PM
Anyone want to make this for 1.3.2? Will pay 500 creds C:

schepers12
02-09-2013, 05:30 AM
@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!

Hall of Famer
02-10-2013, 12:06 PM
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.

Micolai
07-28-2020, 08:53 PM
Is this able to be updated to the current 1.3.4?