Home Community Mys-Script Creative Off-Topic |
|
|
Thread Tools | Display Modes |
#1
|
||||
|
||||
Health and mood system + progress bars
-What we will do-
Create a health and mood system to make pets less static. Once finished, this can easily be added on to to create things like hunger, thirst, etc. After this initial post, you can read the post afterwards if you wish to include any addons, such as pets dying when health reaches 0. -Step 0- First we need to go to phpMyAdmin and add a new column in the owned_adoptables table: Quote:
-Step 1- Now go to class_ownedadoptable and add these lines with all the other public and protected stuff: PHP Code:
PHP Code:
Here comes the fun part: Progress Bars! Percents and values can get so boring sometimes, so we're going to use progress bars. Go to the css folder (located in the root folder, not your template css) and create a new file called "progress.css" Inside, paste this: PHP Code:
In order to see your new progress bar's style, you have to add this to your header.tpl: PHP Code:
Go to myadoptsview.php and add these under "public function manage": PHP Code:
PHP Code:
Aren't they spiffy? -Adding and Removing Mood/Health- How exactly you want to update the health and mood is up to you (Whether it's toys, medicine, clicks, etc.) But however you do it, you would do this to edit health: PHP Code:
PHP Code:
-Decrease needs daily- Add this to your myadoptsview.php file, inside the manage function: PHP Code:
And you're all set! Please note that the code above is assuming that you already have $subHealth and $subMood already defined. Just in case you don't: PHP Code:
So if the mood drops to 0, then the health begins to drop by 10 every day. The only issue with this code is that the user has to click on the pet and refresh the page/interact with it in some way in order for this to take effect, so pets' needs could be frozen if the user just doesn't click on them, sort of cheating the system. It works alright as a prototype system though, since I couldn't figure out a better way to get it working.
__________________
Last edited by Dinocanid; 04-02-2017 at 04:50 PM. Reason: Updated to add decreasing needs |
|
|
What's New? |
What's Hot? |
What's Popular? |