Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Mys v1.3.x Mods (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=42)
-   -   Mys v1.3.4 Display Pet's Birthday / Original Owner (http://www.mysidiaadoptables.com/forum/showthread.php?t=4826)

Kyttias 04-20-2015 12:40 AM

Display Pet's Birthday / Original Owner
 
This mod could also be used for other things. The basic concept is that you have some bit of information you need associated with a pet but that bit of information needs to be attached to them when they are born or otherwise created by the system.

Database
Open up phpMyAdmin so you have access to your database, and open up the owned_adoptables table. We're going to create two new columns.

You can add these columns by pressing Structure and, at the bottom of that page, observing where you can type in '2' to add 2 columns at the end of the table, and pressing 'Go'.

Both will be stored as the VARCHAR type, originalowner with a length of 20, birthday with a length of 30. I recommend you fill birthday with a default value formatted such as "April 20th, 2015" and all existing pets will have this date set as their birthday. You can do the similar with originalowner, but if it's more fitting for your needs, leave it blank.

Alternatively, you can instead use the following query by opening the SQL tab instead of the Structure tab:
Code:

ALTER TABLE adopts_owned_adoptables ADD `originalowner` varchar(20) NOT NULL  DEFAULT '',
ALTER TABLE adopts_owned_adoptables ADD `birthday` varchar(20) NOT NULL  DEFAULT 'April 20th, 2015'

If your default prefix for your database is not adopts_, you'll need to edit the code above first!
Pet Creation Areas
Pets can be created through five different means so code needs to be changed in each place. In classes/class_stockadopt.php pets are created for adoptable shops, in classes/class_promocode.php, pets are created from user entered promo-codes, in classes/class_breeding, pets are created via two pets being bred together to make offspring, in adopt.php the pets are created from a list of always available pets for free, and finally, in admincp/ownedadopt.php you can, as admin, give new pets directly to members. Open all of these files up and look for this, it only happens once in each of these five files (be sure not to miss a single file):

PHP Code:

$mysidia->db->insert("owned_adoptables", array( 

Make sure that it does say insert, not update. We're only looking to make additions to the insert function. Observe this line and try to wrap your head around what's going on -- that's right, these correspond directly with the column names in the database.

Alright, anywhere in these lines, I prefer at the end, we're going to add references to our new database columns and what we want to be in these fields.

PHP Code:

"originalowner" => $mysidia->user->username"birthday" => date("F jS, Y"

Psst, an example of how the birthday field will display itself is "April 20th, 2015". If you'd like to store data differently, look into how PHP formats dates.
Displaying Information
Unfortunately, the method I'm using on my own site is kind of hack-y and simply rewrites the error page announcing "you've already clicked this pet today". This isn't the most desirable nor elegant approach. So this is not a guide to making profile pages for your pets as I have done on my own site.

However, sticking with the original framework, pet stats can be found from a pet's management page where only the current owner can find this information. If you open up classes/class_ownedadoptable.php and find public function getStats() you'll be able to add information in this location, for example, by modifying the $adoptStats variable to include references to $this->originalowner and $this->birthday which each correspond to the values found in the columns we added to the database:

PHP Code:

$adoptStats "<br>Original Owner: {$this->originalowner}<br>Birthday: {$this->birthday}<br>Trade Status: {$this->tradestatus}<br> Current Level: {$this->currentlevel}<br>Next Level: {$nextLevel}</b>"

This mod is very similar to Wallie's Pet Stats/Skills mod which is the same basic concept - adding columns to the database to hold new pet information, making sure this information is created when the pets are created, and displaying it. Wallie's thread attempts to go into detail about displaying pet information in other ways, and I based my own pet profile pages after what I learned there, so it may or may not be of help - it depends on how well you can wrap your head around code. However, Wallie's version is specific to v1.3.3, and some things have changed slightly.

Abronsyth 11-18-2015 11:07 PM

(Super late reply but oh well)

This is splendid! Thank you for sharing :) I really appreciate the little tips and clues you include in all of your mod posts, as well!

(Now to figure out how to give pets public profiles, haha!)

SilverDragonTears 01-15-2017 09:03 PM

It's giving my adopts a birthday a day ahead of what it really is. Suggestions?

Silver_Brick 01-16-2017 06:51 AM

did you added the Database correctly i am sure the mistake is in database because i was also getting same problem but it is solved now by just re doing the things

SilverDragonTears 01-16-2017 08:46 AM

Quote:

Originally Posted by Silver_Brick (Post 35622)
did you added the Database correctly i am sure the mistake is in database because i was also getting same problem but it is solved now by just re doing the things

I did that as well and it's still not working.

Silver_Brick 01-16-2017 09:06 AM

then i think its your website timing problem and i think it is using your computer time or any think maybe you can search the forum and find the thread by kyttias where they posted about website timing maybe it will help :)

SilverDragonTears 01-16-2017 09:28 AM

Thank you :) I will do that.

KrinklyKrisps 03-03-2017 05:14 PM

so cool dude


All times are GMT -5. The time now is 04:29 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.