![]() |
Held Items & Pet Companions
Hello everyone!
Figured I'd post this little mod here today that I recently completed. Preview: http://i.imgur.com/uBW8dhK.png 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:
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:
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:
PHP Code:
Finally, wherever you want to display the item and companions for your pets, go there and add this bit of code: PHP Code:
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! |
PHP Code:
Personally, rather than creating getWhatever() functions I'd rather just set the values to public variables at the top of the owned adoptables class file, and then just use $adopt->companion instead of $adopt->getCompanion() but that's just my preference. That way I don't have to write a function and it looks less clunky. |
I've tried that but it gives me this every time:
HTML Code:
Fatal error: Call to undefined method stdClass::getCompanion() in /home/mysgardia/public_html/functions/functions_items.php on line 194 HTML Code:
Fatal error: Call to undefined method StockItem::remove() in /home/mysgardia/public_html/functions/functions_items.php on line 202 |
Don't you already update the companion and delete the item in your existing functions???? The error has nothing to do with my code. I'm starting to think you removed your function and replaced with just my if statement -- all my code does is transform an old companion, if such a thing exists, into an item again.
PHP Code:
|
Ahhh noo that's exactly what I did. Simply added your code to my code right where you've put it and I get those errors. I've tried doing this before but written a little differently and I always get the weird stdClass error line.
|
Mnn... it might be because the $adopt is a direct reference to the database but not to the class file. getCompanion() is in two places - try it like this, maybe?
PHP Code:
|
See post #3, lol.. :x
When I use $adopt->companion, it gives a different error, doesn't remove the used item, doesn't update the database column with the new item, but it does give back the item currently in the companion column. |
OK WOW I figured out what the issue is after taking a break and coming back to this. I'm so dumb lol
Here's the modified code: PHP Code:
I also made two new item functions that remove the companion/held item and replaces it with the default text. So if a user just wants to remove the item without giving a new one they can do so. Will get first post edited soon. |
Awwww yeeeesss! Thank you for sharing this!
|
Okidokes, here's the two other item functions to remove companions and items without giving new ones. I named the functions "unbindingcompanion"/"unbindingitem", so if you want to name it something else just change that and be sure to match up everything else.
Add in functions_items.php: PHP Code:
PHP Code:
|
All times are GMT -5. The time now is 03:49 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.