Home Community Mys-Script Creative Off-Topic |
|
|
Thread Tools | Display Modes |
#1
|
||||
|
||||
Achievments system
-What This Does-
Users are able to unlock achievements by completing certain tasks, owning certain adoptables, or owning certain items. This is the same system I use on my site. -How This Works- There is no adminCP functionality, so new achievements have to be coded in manually; especially if you want the conditions to be complex. The example achievement goes by "fullpantry", but you can change the name to whatever since I was just too lazy to do it myself for the sake of this tutorial. -Step 1- To get started, we need to create two php files. In your public_html folder, create a new file called achievements.php. We're going to make a simple achievement that unlocks when a user owns a certain amount of adoptables. Inside achievements.php, paste this: PHP Code:
You will most likely never have to touch the above code again. Now go to your view folder and create a new file called achievementsview.php. Inside, paste this: PHP Code:
Looking at it now, this code is supposed to unlock when a user owns 10 or more adoptables. The images are used for the achievement images. I recommend using a "mystery image"/silhouette for the locked items and a normal image for the unlocked one. -Step 3- Now we go to myadoptsview.php and add this in public_function index: PHP Code:
Now we go to phpMyAdmin. Go to adopts_users_status and create a new column with this information: Code:
Name: fullpantry Type: VARCHAR Length/Values: 8 Default: (as defined) locked Collation: latin1_swedish_ci Check the null box Comment: Milestone Start Simple, enough? Now we have an achievement that unlocks when the user owns 10 or more pets. It uses tooltips for the descriptions, so go here if you want to know how those work. -Pet based achievements- Now what if you want to reward the user for owning a certain pet? In your achievmentsview.php, you would add this line under $status, PHP Code:
PHP Code:
PHP Code:
Code:
Name: OwnCertainAdopt Type: VARCHAR Length/Values: 8 Default: (as defined) locked Collation: latin1_swedish_ci Check the null box To reward a user for owning a certain item, follow the same formula by adding this with all the other "check" code: PHP Code:
PHP Code:
PHP Code:
Quote:
Having trouble making your own conditions? Just reply to let me know and I'll try to help you out!
__________________
Last edited by Dinocanid; 01-20-2017 at 06:07 PM. |
#2
|
||||
|
||||
Nice!!! Thank you for sharing!
|
#3
|
||||
|
||||
Can you help me? Where exactly does this go?
PHP Code:
|
#4
|
||||
|
||||
It would go in like this (following the example in step 2):
PHP Code:
__________________
|
#5
|
||||
|
||||
Thank you :)
So once you unlock it the locked images go away? |
#6
|
||||
|
||||
Yep. The code is set up so the locked image only appears when it was "locked" in phpMyAdmin. Same goes for the unlocked image, which only appears when said achievement says "unlocked" in phpMyAdmin; so they can't appear at the same time.
__________________
|
#7
|
||||
|
||||
What would be some other achievement ideas to add to this?
|
#8
|
||||
|
||||
Hmm maybe for amount of money reached? Or number of clicks per day. That's all I can remember besides owning certain creatures or items.
__________________
asp.net stole my soul. |
#9
|
||||
|
||||
I added a part for item-based achievements. I didn't test it myself though, so let me know if it causes any errors or doesn't work.
Amount of money reached sounds simple enough, but I'm not sure where the amount of clicks from a user is stored to be able to call it.
__________________
|
#10
|
||||
|
||||
It's not stored I think, you'd have to count it with rowCount() from the table vote_voters
__________________
asp.net stole my soul. |
|
|
What's New? |
What's Hot? |
What's Popular? |