PDA

View Full Version : Mys 1.3.3 Background Mod


Hwona
04-15-2015, 09:58 AM
This is a simple background mod for displaying backgrounds on adoptable pages. Please save a backup of your entire site before using this mod as I can't guarantee it will work - my own site uses this system but it's heavily moddified and the coding is likely quite different for these pages. I apologize if anything breaks because of this or if the instructions are too confusing.

__________________________________________________ _____

These are the edits for the files:
In class_ownedadoptable.php, add below the list of "protected stuff":
protected $background;
below all the public functions, add:
public function getAdoptBackground(){
return $this->background;
}

In levelup.php:
inside of the click function, below $mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$date = new DateTime;
$ip = secure($_SERVER['REMOTE_ADDR']); add:
$background = $this->adopt->getAdoptBackground();
below: $mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$date = new DateTime;
$ip = secure($_SERVER['REMOTE_ADDR']);
$background = $this->adopt->getAdoptBackground();
add: $message = "<div><div style='text-align:center;background-image:url({$mysidia->path->getAbsolute()}picuploads/backgrounds/{$background}.png);'><br><img src='{$mysidia->path->getAbsolute()}levelup/siggy/{$this->adopt->getAdoptID()}'></div>";

In functions_items.php:
below all the functions, add:
function items_background($item, $adopt){
$mysidia = Registry::get("mysidia");
// Update the lastbred info.
$background = $item->backgroundimage;
$mysidia->db->update("owned_adoptables", array("background" => $background), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
$note = "Your adoptable now has a new background!<br>";
//Update item quantity...
$delitem = $item->remove();
return $note;
}

In the picuploads folder, make a new folder called "backgrounds" and fill it with all your different background image files. They must all be png files!!! Give each file an alpha numeric name with NO SPACES!
__________________________________________________ ______

Now, let's edit the database

In the items_functions table, create a new row - put "Background" in the function column and "Adoptable" in the intent column. Put a description in the description column.

Now, in the items table, add a column of varchar(200) latin_swedish_ci with a default value of NULL called "backgroundimage"

__________________________________________________ ______

Now, let's make your first background

create a new row in the items table as a new item. Name your background, set the price, stock, etc.
Except. in the function column, put "Background" and in the "backgroundimage" column, put the name of the file you want to serve as the background (just the alphanumeric name). Do not include the path to the folder or the .png!

__________________________________________________ ______

That should be it!

Kyttias
04-15-2015, 10:41 AM
Nice use of $mysidia->path->getAbsolute()!

Missy Master
04-15-2015, 12:11 PM
oh I woke up to this and it made my whole day :)

Thank you and Kyttias both for all your help trying to get this going, yay, a MOD for it!! *dances*

Hwona
04-15-2015, 04:46 PM
Does anyone know if this works? I can't test on my testing site because nothing works on it right now. As for my main site, I can't tell from the code.

Missy Master
04-15-2015, 05:03 PM
Followed it all to the letter and for 1.3.4 everything loads fine, but when I go to use the BG I am getting:

An error has occurred.

The item function is invalid


However! I think its because its 1.3.4!

Going to try this on 1.3.3 now! I am sure its going to work there, no idea why it isn't working for 1.3.4, I looked everything over and didn't see what could possibly be wrong --- however not everything for 3 will work for 4.

If anyone else wants to take a look and see why it might not work for 1.3.4?

This is a REALLY good and important Mod, be great to have for the new script!

Hwona
04-15-2015, 05:10 PM
Followed it all to the letter and for 1.3.4 everything loads fine, but when I go to use the BG I am getting:

An error has occurred.

The item function is invalid


However! I think its because its 1.3.4!

Going to try this on 1.3.3 now! I am sure its going to work there, no idea why it isn't working for 1.3.4, I looked everything over and didn't see what could possibly be wrong --- however not everything for 3 will work for 4.

If anyone else wants to take a look and see why it might not work for 1.3.4?

This is a REALLY good and important Mod, be great to have for the new script!

I remember trying to help Kyttias implement the stat system on 1.3.4... that script displays everything using 2 files I think... I never was able to figure it out. XD

Missy Master
04-15-2015, 05:34 PM
I was able to implement adding in items that are shown under the Pet image a long time ago in 1.3.4, and I compared that item function to this one, and I swear I don't see whats missing or wrong! xD

There's likely just ONE thing I am missing somewhere.

Now I'm setting up a 1.3.3 site to test this, and getting all the Strict Standards and headers already sent stuff


Strict Standards: Declaration of File::getBasename() should be compatible with SplFileInfo::getBasename($suffix = NULL) in /home/petsim/public_html/Etheria/classes/class_file.php on line 19

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/petsim/public_html/Etheria/classes/class_file.php:19) in /home/petsim/public_html/Etheria/classes/class_session.php on line 13

Warning: Cannot modify header information - headers already sent by (output started at /home/petsim/public_html/Etheria/classes/class_file.php:19) in /home/petsim/public_html/Etheria/classes/abstract/abstract_usercreator.php on line 24

Warning: Cannot modify header information - headers already sent by (output started at /home/petsim/public_html/Etheria/classes/class_file.php:19) in /home/petsim/public_html/Etheria/classes/abstract/abstract_usercreator.php on line 25

Warning: Cannot modify header information - headers already sent by (output started at /home/petsim/public_html/Etheria/classes/class_file.php:19) in /home/petsim/public_html/Etheria/classes/abstract/abstract_usercreator.php on line 24

Warning: Cannot modify header information - headers already sent by (output started at /home/petsim/public_html/Etheria/classes/class_file.php:19) in /home/petsim/public_html/Etheria/classes/abstract/abstract_usercreator.php on line 25


Plus it wont let me stay logged in lol!! So I will test this on 1.3 but its gonna take a bit!

Gotta work this out cos there are a lot of mods for 1.3.3 I really want to use, so .. I just need to get this going.

Missy Master
04-15-2015, 05:53 PM
Okay I had forgotten for 1.3.4 we go to class_privateitem and add:


case "Background":
$message = items_background($this, $owned_adoptable);
break;


SO!

Action Completed!
Your Pet now has a new background!

I was able to add it and it gave me a success, but it isn't showing up yet for this pet --- so gonna see what else I need to do!

This is for 1.3.4 !

Missy Master
04-15-2015, 06:45 PM
Okay this might help someone sharper than me --

this is 1.3.4, it says the item is applied and congrats new BG etc, and the amount IS going down in my stock!

But no BG shows up on the profile in my adopts, and not in levelup either, until you try to level a SECOND time --- and you get this -- this is the top third of the background image repeated three times!



http://pet-sim.com/Canidae/Error.png

Hwona
04-16-2015, 07:51 AM
I only have part of a background mod... the BG only shows up on the click page... for now. The problem is the adoptable images for signatures. In order to have backgrounds in those pictures, you need a system that saves a new image - each adopt needs to have its own individual image. I know this is possible ... I just don't know how to code this. Also, there may be a problem with this for sites with tons of pets. That's a lot of images to have to store.

Missy Master
04-16-2015, 11:49 AM
Oh I see :)

I saw on Caterpiller Cave you were offering backgrounds but I didn't realize that wasn't a finished Mod. The site really does look amazing by the way!!

And yes most of the pets on my sites do have unique images in imageurl. I think I might just give up on this background idea, it;s starting to get really upsetting because I am frustrated and now I'm getting others frustrated with me because I don't understand the coding. :(

Thanks for your help, I appreciate it.

Hwona
04-17-2015, 10:30 AM
No, it's fine. Actually, for my site I'm planning on a different use for backgrounds, so I don't need the background images in siggies, but I can see what I can do...

Missy Master
04-17-2015, 10:39 AM
Yeah for me I wont be using it for siggies either, just want for the profiles really.

We've got something thanks to Kyttias that works for 1.3.4 now!! :)

I will try to get it into a Mod form over the weekend if Kyt is okay with that, its basically not my coding at all so I don't want to just take it and do that ..

Corsair
12-02-2016, 09:28 PM
Does anyone happen know how to get this to work?

I keep getting a The item function is invalid message

function items_recipe($item, $adopt){
$note = "The item {$item->itemname} is a recipe item, which cannot be used on any adoptable and can only be useful if you are performing alchemy.";
return $note;
}

function items_gender($item, $adopt){
$mysidia = Registry::get("mysidia");
$delitem = $item->remove();
$gender = $adopt->gender;
switch($gender){
case "m":
$newgender = "f";
$newgender_full = "girl";
break;
default:
$newgender = "m";
$newgender_full = "boy";
}

$mysidia->db->update("owned_adoptables", array("gender" => $newgender), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
$note = "Success! The <b>{$item->itemname}</b> has worked its magic. {$adopt->name} is now a {$newgender_full}.";
return $note;
}

function items_background($item, $adopt){
$mysidia = Registry::get("mysidia");
// Update the lastbred info.
$background = $item->backgroundimage;
$mysidia->db->update("owned_adoptables", array("background" => $background), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
$note = "Your adoptable now has a new background!<br>";
//Update item quantity...
$delitem = $item->remove();
return $note;
}

Hwona
12-03-2016, 02:22 AM
Did you update class-privateitem.php?

You need to a case and break for the background item function.

Corsair
12-03-2016, 10:20 AM
I got it working but now I'm getting a database error

Database error 1054 - Unknown column 'background' in 'field list'

http://i137.photobucket.com/albums/q203/Roconza/Untitled-1_zpswsytncq1.png~original

http://i137.photobucket.com/albums/q203/Roconza/Untitled-2_zps1ttprec4.png~original

lotus
12-03-2016, 02:53 PM
Did you add a background column to the owned_adoptables db? Try setting it to "Blank" as default for pets who don't have one.

edit: You have a background1 column in the items db instead of the owned_adoptables.

Corsair
12-03-2016, 04:00 PM
Edit: I got it to work.

Silver_Brick
01-17-2017, 02:54 AM
perfect mod