![]() |
How to give users more ways to earn money?
I was thinking about a 'Jobs' page.
They can click on a button from time to time to earn some extra money? Or is it only possible to earn money through the daycare? I don't want people to earn a lot with clicking eggs. But I don't want people to end up poorly without any money to buy the expensive stuff. Just to add more to my website, if this is ridiculous I'd like to know about that too. |
There's always the itemdrop mod. They get items for clicking creatures, and they can then sell them.
Um...you can give out a promocode for free items. |
It's possible, "Giving money" is just an update to the database. It requires some understanding of php. I can guide you through all steps, please tell me if you didn't understand, I don't explain stuff well.
1) Create a new page, by creating two .php files (it's how you create a yoursite.com/pagename instead of a yoursite.com/pages/view/pagesname):
PHP Code:
2) If you go to yourwebsite.com/jobs the page should exist now. This is how the two files work as a page:
3) To add text to the page you do this: $document->add(new Comment("content that can have html as well.")); If you want to respect the View-Controller, this would be done in the view. If you check the page yourwebsite.com/jobs, the text should be there 4) Now, we need something for the user to click to request money. Like a button saying "Work!". However, in order to submit something, to send information somewhere, a "trigger" needs to exist. So we attach the button to a Form. Forms can have multiple elements to request information from the user (textfields, radio buttons...) and then a nice button in order to send the form with the information. In this case, a form with a single with a button is enough, since you just want a little button to send money. Users click and money is sent. To add a form with a button to the page you do this: PHP Code:
5) This part needs some understanding of if conditions in programming and scope. To check if the button submitted, you add this to the page: PHP Code:
PHP Code:
PHP Code:
Open the database with phpMyAdmin or whatever infertace used to facilitate the control of the database. You will see multiple tables. In the (prefixYouChose)_users, add a new column called lastWorkTime for example, with a type varchar, size 20, can be null and the predefined value for when it's null is NULL (if it asks you for that). Usually you go in structure and then there must be a place to add a column to the table. Everyone should have that column set to null now. Open the file class_member.php and add the new variable you created to the top next to other ones. Below __construct() create a function to check the user's last time working and another to update this time. PHP Code:
PHP Code:
|
Oh item drop sound nice too. I like that idea.
Actually I understood all your steps perfectly, I will try this as soon as possible. It pretty much sounds how I want it to be. //edit: So far it works. |
Is there a possibility to add more jobs?
Or can I only add one? Also, how do you disable the button after it's clicked? I looked on google but that didn't make me smarter. |
Does the button need to be disabled if the database checks and only gives money once a day? You shouldn't need to.
IntoRain, I love this mod! You should make a thread for it. |
Quote:
|
Maybe add a blurb to the else clause?
You have already claimed your daily paycheck. Come back tomorrow for another! |
This sounds like a very cool script! I hope this will be expanded upon a little bit, kuz I think this is what Mysidia is about. Helping creatures to grow, and also giving incentives for people to keep coming back. This makes people want to come back for more, and I'd highly recommend working on this further to make it into an actual extension of Mysidia :3
|
Glad to see it working! ^^ To add more, the "simplest" but kinda tiring process would be to repeat the very same but by creating more buttons, and more columns in the database and more similar functions to match. I will try to make a more easily editable version and a little better coded, once I have a bit of time available to write it x.x
Thank you guys for the support! ^^ I have a mod ready I'd like to post first, but I will try to improve and post this one asap! Regarding the button, you'd have to use jQuery to disable it I believe(http://stackoverflow.com/questions/1...-submit-button). A way to go around mysidia's hate on javascript, is to add the script inside a Comment(""), inclusing the addition of the jQuery link, works great. If you don't want to show the button at all: PHP Code:
PHP Code:
|
All times are GMT -5. The time now is 10:17 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.