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 Code:
$GLOBALS['isloggedin'] = $isloggedin;
$GLOBALS['username'] = $username;
$GLOBALS['loggedinname'] = $username;
$GLOBALS['money'] = $GLOBALS['usersettings']['money'];
$GLOBALS['group'] = $usergroup;
and add this underneath it:
PHP Code:
$GLOBALS['houses'] = $houses;
find:
PHP Code:
$luid=$GLOBALS['usersettings']['uid'];
$lsess=$GLOBALS['usersettings']['session'];
$usergroup=$GLOBALS['usersettings']['usergroup'];
and add this line underneath them:
PHP Code:
$houses=$GLOBALS['usersettings']['houses'];
__________________________________________________ _________________________________________
next, edit adopt.php:
include this line at the beginning:
PHP Code:
include("functions/functions_houses.php");
find:
PHP Code:
// 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 Code:
if ($freespace > 0) {
and put before:
} // This bracket ends the else statements for whether or not an ID was entered
PHP Code:
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 Code:
include("functions/functions_houses.php");
on top
find:
PHP Code:
if($isloggedin == "yes" and $userstatus['canbreed'] == "yes"){
and add underneath it:
PHP Code:
if ($freespace > 0) {
find:
PHP Code:
}// this is the end of if($isloggedin == "yes")
and add this above it:
PHP Code:
}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 Code:
include("functions/functions_houses.php");
and find:
PHP Code:
if($isloggedin == "yes"){
add underneath it:
PHP Code:
if ($freespace > 0) {
next, find:
PHP Code:
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 Code:
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 Code:
include("functions/functions_houses.php");
find:
PHP Code:
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 Code:
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 Code:
if($isloggedin == "yes" and $userstatus['canpound'] == "yes"){
this:
PHP Code:
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 Code:
$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 Code:
($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 Code:
$function_houses = "{$dir}functions/functions_houses.php";
include($function_houses);
adopt.php:
find:
PHP Code:
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 Code:
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 Code:
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 Code:
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 Code:
$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 Code:
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 Code:
// 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 Code:
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 Code:
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 Code:
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.