View Single Post
  #1  
Old 06-30-2014, 05:39 PM
Missy Master's Avatar
Missy Master Missy Master is offline
Pet-Sim.Online
 
Join Date: Jan 2010
Posts: 475
Gender: Unknown/Other
Credits: 46,679
Missy Master is an unknown quantity at this point
Default 1.3.4 Item Add Mod To Pets: Reworked [Part One]

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! :)
Attached Files
File Type: php class_privateitem.php (6.4 KB, 3 views)
File Type: php class_ownedadoptable.php (8.8 KB, 6 views)
File Type: php functions_items.php (13.2 KB, 3 views)

Last edited by Missy Master; 05-10-2015 at 08:57 PM.
Reply With Quote