1.3.4 Item Add Mod To Pets: Reworked [Part One]

Forum
Last Post
Threads / Messages

Milly Money

Pet-Sim.Online
Staff member
Dev Staff
Joined
Jan 27, 2010
Messages
538
Points
18
Mysidian Dollar
28,331
Before you start:

One complication is that all your pets -- those from adoptions, breeding, whatever --will need an imageurl in their owned_adoptables table. Still working on how to ensure that, so .. I'd say that needs to be next to make this a finished solution that all may use.



I have re worked this, and attached my files for my heavily modded site, so if there is any question that might help. ALL credit goes to Kyttias for her help in coding all this!! :)

I may have missed something, or made a mistake somewhere, or omitted something. In case I have ...be sure to back up ALL PAGES AND the SQL!

This gives you a way to add item 'slots' that will show items/toys/whatever in front of your Pets. I am working on one that will add backgrounds right now too.

This is for 1.3.4 !!


First : BACK UP all pages and the database --- preferably leave ALL pages open you are modding so you can do an undo if you have to do it!

I had this code much more difficult than it needed to be. Here's a far more streamlined version!



1. In functions_items.php in your functions section. We need to add a function for each item slot we are adding.

Replicate this code, and change the name for each slot, and you can have as many as you like! [ don't forget to add the actual fields in owned_adoptables!! ]

Add this code for the new function - for every field you want to add for this, in other words, how many 'slots' you want to add for plushes/items/toys etc to be added to your Pets - you will add another of this code, the only difference will be you will name them something different - ie, toy_2, toy_3 and so on. You can have as many as you want, really, but remember to update the breeding and adopt insert and update statements, basically anywhere the owned adopts table gets added to, you want to be sure you allow for the new fields!

For me, I have toy_1 all the way to toy_5 and it works really great.

I simply named this function click5, and then added 6, 7 etc. You can call them whatever you want, but you will need a new function for each item slot you want to add!



Code:
function items_click5($item, $adopt){
  $mysidia = Registry::get("mysidia");
  $newclicks = $item->value;


  $mysidia->db->update("owned_adoptables", array("toy_1" => $newclicks), "aid='{$adopt->aid}'and owner='{$item->owner}'");
  $note = "You added a {$item->itemname}, and the Pet has just received a {$item->value}<br>";
  
  
   //Update item quantity...
  $delitem = $item->remove(); 
  return $note;
}


2.

Then in class_ownedadoptable.php :

ADD [ near the very top ]:


Code:
protected $toy_1;

Add one of these for each item slot you are adding.

then ADD:


Code:
public function getToy_1(){

	    return $this->toy_1;

	}

Add this for every item Slot!!

RIGHT UNDER THAT --- ADD THIS! ***Please note: This assumes you create five item slots --- if you want more or less, just omit the lines for the extras --- or add MORE!!

Code:
public function getImage($fetchMode = ""){
    $mysidia = Registry::get("mysidia");
    if($this->currentlevel == 0) return $this->getEggImage($fetchMode);
    
       
    if ( $this->toy_1 ){ $toy_1 = "<img class='layer' src='{$mysidia->path->getAbsolute()}picuploads/{$this->toy_1}.png'>"; } 
    if ( $this->toy_2 ){ $toy_2 = "<img class='layer' src='{$mysidia->path->getAbsolute()}picuploads/{$this->toy_2}.png'>"; }
    if ( $this->toy_3){ $toy_3 = "<img class='layer' src='{$mysidia->path->getAbsolute()}picuploads/{$this->toy_3}.png'>"; } 
if ( $this->toy_4){ $toy_4 = "<img class='layer' src='{$mysidia->path->getAbsolute()}picuploads/{$this->toy_4}.png'>"; } 
    if ( $this->toy_5){ $toy_5 = "<img class='layer' src='{$mysidia->path->getAbsolute()}picuploads/{$this->toy_5}.png'>"; } 
    $layers = "<div class='petcontainer'>
        
        <img class='layer' src='{$this->imageurl}'>

".$toy_1."
".$toy_2."
".$toy_3."
".$toy_4."
".$toy_5."

        </div>";

    return $layers;            
}


Remember, toy_1 is the extra field we will are adding in the database for owned_adoptables. You can call it anything you like, and you can add several of these fields, just add more of the above code here ( toy_2, toy_3 etc ) and add as needs be to breeding.php and adopt.php --- ANY where that there is an insert for owned_adoptables that needs to reflect the new fields.


3.

In phpmyadmin, add in owned_adoptables :

toy_1 varchar (100) Not Null

Repeat for as many 'slots' as you want. Add ten for tons of items and toys slots for each pet! :)


4.

In class_breeding.php and adopt.php, add in to the insert statements :

"toy_1" => '',

If you add more than one, add as you need.


"toy_1" => '',"toy_2" => '',"toy_3" => '',"toy_4" => '',"toy_5" => etc



5. In picuploads folder, upload the images you will be using for your toys or rewards or whatever.

They ALL need to be .png

Add a TRANSPARENT image and call Empty.png. It needs to be the square shape of your largest Pet image. Easiest way to create it is just use the image or your largest Pet and then create it out of that. Upload that to picuploads and images folders.

6. Go to class_privateitem.php, and add this where you see all the others like this [ around line 55 ]:


Code:
case "Click5":
             $message = items_click5($this, $owned_adoptable);
             break;



7. Create the toy/reward/item for a Pet in the Item Create.

Name it whatever you wish, remember it needs to be a .png.

Item image: the full exact url of the image location.
Function: Click5, Click6, etc
Target: All
Value : Whatever the name is of the image.

If it's Kittycat.png, you will put Kittycat for value. Not with .png, just Kittycat.

YES the item can be traded.

YES the item can be consumed. ( otherwise it won't allow you to use it )


Create the new item, and then do a run through of buying it and equipping to a Pet. If all goes well you will see it added to the Pet in its Profile! :)
 

Attachments

  • class_privateitem.php
    6.4 KB · Views: 3
  • class_ownedadoptable.php
    8.8 KB · Views: 6
  • functions_items.php
    13.2 KB · Views: 3
Last edited:
Pongo.png


This is to give you an idea what your stats should give you ....she has her cute little plushie (courtesy of Wallie!! ) down there in his collection ...
 
I am currently working on how to insert more toys in successive slots --- will update.
 
Ooh, this looks really interesting... is it like a trinket system?
Edit: DO you know which versions this is compatible with. :3
 
Last edited:
You can add literally anything ...rewards, pets for pets, toys, jewels .. and this is for 1.3.4 but it might work for 1.3.3 ?

I'd say try it carefully!


If you mess with where it's set out as a .png file expected, I bet you can use .gif too for animated goodies!
 
Oh, if you'd like, I can make some trinket images for users to use on this mod. :3
 
Oh right! I wanted to suggest adding an "empty item" like when no item i present, showing another image. Then, provide that item free in a shop. :3

Edit: Oh! One more thing, I caught a problem! If you want to use "click5' for the name, every appearance of "click2" needs to be changed. The last part of the mod changes the name from "click" to "click5".
 
Last edited:
Oh okay, I will check that out, thanks!! :) And yeah I'd like to have something for the empty slots instead of a broken image icon ... not sure how to code that yet.
 
Could I try to build off of this mod? I'm probably going to fail, but... :3
 
I have found a bug to this, when you activate an item with this to a Pet with more than three levels, for some reason it sends it back to egg. Likely is the base code used .. will have to work on this when I can ...
 
Oh this looks good so far, why dont you provide all files edited in a .zip or .rar file for new users who have fresh installation or simply never touched the same files you've edited? It will make their lives easier, at least to me. XD
 
I haven't forgotten this Mod, will update it as soon as we can use items again on my site :)
 
I have re worked this entire Mod, to go with the whole removal of items Mod that will be posted next --- this allows for layering of items and ALL credit goes to Kyttias for her help in coding all this!! :)
 
ooh! Question! OwO Would this by any chance be able to be used for mutations? So like you can make it like an item but it appears on the pet as an add on to their lines, etc? Only problem is, I wouldn't know how to make it work with breeding and stuff, but one step at a time XD
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top