Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Tutorials and Tips

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-29-2016, 04:26 PM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 50,831
tahbikat is on a distinguished road
Lightbulb Held Items & Pet Companions

Hello everyone!


Figured I'd post this little mod here today that I recently completed.

Preview:



Again as with my other mod (Species Rarity w/ Images!), you'll want a public pet profile mod in place. See this post: Clicky
This mod can work elsewhere, like the creature's manage page and such. You'll just need to make your own edits for that!

Alrighty, so we'll be modifying a few files as well as adding new item functions in the database. First go to your class_privateitem.php file in your classes folder.

Go to around line 50 where you see a list of item functions, and under them add this:
PHP Code:
         case "Companion":
            
$message items_companion($this$owned_adoptable);
            break; 
         case 
"HeldItem":
            
$message items_helditem($this$owned_adoptable);
            break; 
Next, go to your database table adopts_items_functions. Look for the Level1 item function and click the "Copy" link. Change the Level1 text to Companion, and change the description to something else like "This item function gives a pet a companion!". Press "Go". Now do this same thing again except change Level1 to "HeldItem". Press Go.

After that go to your database table adopts_owned_adoptables. We'll be adding two new columns called "companion" and "item". VARCHAR 60, latin1_swedish_ci. For default, put "noitem" for the item column, and "nocompanion" for the companion column. Press Go to save. You're done in the database now.

Now go to your functions folder, and to the functions_items.php file. Add this code to the file, preferably at the bottom, to get your new companion and held item functions added.
PHP Code:
function items_companion($item$adopt){ 
  
$mysidia Registry::get("mysidia"); 
   
  if (
$adopt->companion != "nocompanion") {   
    
$itemgive = new StockItem($adopt->companion);   
    
$itemgive->append(1$mysidia->user->username);   
    }  
     
  
$companion $item->itemname
  
$mysidia->db->update("owned_adoptables", array("companion" => $companion), "aid ='{$adopt->aid}' and owner='{$item->owner}'"); 
  
$note "You have given your pet a <b>{$item->itemname}</b>! It will now show up in your pet's profile. <br /><br /> <a href='http://mysgardia.com/inventory'><button type='button'>Return to Inventory</button></a><br>"
  
//Update item quantity... 
  
$delitem $item->remove();  
  return 
$note
}  

function 
items_helditem($item$adopt){
  
$mysidia Registry::get("mysidia");
  
  if (
$adopt->item != "noitem") {  
    
$itemgive = new StockItem($adopt->item);  
    
$itemgive->append(1$mysidia->user->username);  
    } 
    
  
$helditem $item->itemname;
  
$mysidia->db->update("owned_adoptables", array("item" => $helditem), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
  
$note "You have given your pet a <b>{$item->itemname}</b>! It will now show up in your pet's profile. <br /><br /> <a href='http://mysgardia.com/inventory'><button type='button'>Return to Inventory</button></a><br>";
  
//Update item quantity...
  
$delitem $item->remove(); 
  return 
$note;


Now in your picuploads folder, you'll need to create a new folder called "items" (for the sake of organization). In this folder you will need to upload the companion and held item images each time you create them. So if you create an item called Rubber Ball, go to this folder and upload the image as "Rubber Ball.png". It MUST have the same exact name as the existing item, along with .png as the extension.

ALMOST finished! Go to your classes folder again, and in class_ownedadoptable.php at the bottom, add this code:
PHP Code:
 public function getCompanion(){
        return 
$this->companion;
        }
        
        public function 
getItem(){
        return 
$this->item;
        } 
Also add these to the top of the file:
PHP Code:
public $companion;
    public 
$item

Finally, wherever you want to display the item and companions for your pets, go there and add this bit of code:

PHP Code:

            
<img src='/picuploads/items/{$this->adopt->getCompanion()}.png' title='Oh look! A {$this->adopt->getCompanion()} is following this creature.'/>
            
            
            <
img src='/picuploads/items/{$this->adopt->getItem()}.png' title='Oh look! This creature is holding a {$this->adopt->getItem()}'/> 
EDIT: Oops! Forgot an important part! Remember when we defined the default values in the database columns as "noitem" and "nocompanion"? In your picuploads/items folder, upload two images named "noitem.png" and "nocompanion.png". These two images will display whenever a pet doesn't have an item/companion. So for example, you might want to upload the image of a red X or question mark or something!

EDIT2: If you want two item functions that completely remove companions and held items from pets and put them back into the player's inventory, see this post: Removal Functions

Phew, all done! Hope you guys enjoy!

Last edited by tahbikat; 04-14-2016 at 05:23 PM.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:08 AM.

Currently Active Users: 831 (0 members and 831 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636