View Full Version : How to give users more way to earn money?
Skaiya
04-01-2014, 10:24 AM
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.
squiggler
04-01-2014, 03:02 PM
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.
IntoRain
04-01-2014, 03:17 PM
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):
One jobs.php (in the main folder together with myadopts.php) and a jobsview.php inside the view folder.
Copy the contents of a file in the same folder to see how pages are done, changing the class name (to JobsController and JobsView, it will throw an error when visiting the page if you did the controller and view wrong) and deleting all other functions, except __construct and index. You can delete the contents of index except for
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("document title here");
In the jobsview.php.
2) If you go to yourwebsite.com/jobs the page should exist now. This is how the two files work as a page:
Usually the visuals of the page go inside the jobsview.php file and the verifications inside the jobs.php. But you can do everything in one file if you want, and ignore the other and it will still work. It's just a way used to separate what is viewed by the user and what isn't.
For example, the contents and text would go in jobsview.php and the database modifications in the jobs.php.
__construct is a function you can ignore, it basically "creates" your page using the definitions of the parent page/class (controller or view). Index() works as the main page (yourwebsite.com/jobs). If you create a function (on both files jobsview.php and jobs.php and the document set up like the code above!) called example(), it would create a page yourwebsite.com/jobs/example.
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:
$form = new Form("form name", "", "post");//create a form
$form->add(new Button("button text", "submit", "submit"));//this adds a button to the form
$document->add($form);//add the form to the document so it shows on the page
After adding this button to the page, clicking will submit but nothing will happen. We need the actual database modification.
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:
if($mysidia->input->post("submit"))//if button submits
{
//whatever is inside these curly brackets will happen if the condition above is true
//try to add some text here, then click the button to see the text appear
}
6) Now, what do you want to do when to do when the button submits? Give money!
if($mysidia->input->post("submit"))//if button submits
{
$mysidia->user->changecash(moneyToAdd);//change moneyToAdd to the amount of money you want the user to get when he clicks the button
}
If you want the money to be random instead:
if($mysidia->input->post("submit"))//if button submits
{
$money = rand(minimumValue,maximumValue);//the random value to add to the money of the user will be between the values you put in minimumValue and maximumValue
$mysidia->user->changecash($money);
}
7) If you want it to have a time limit, you need to modify the database in order to save the user's last time requesting money. In this case I will use once per day.
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.
public lastWorkTime;
//(__construct here)
//function to check if he can work today
public function canWork(){
$dateTime = new DateTime;
$todayDate = $dateTime->format('Y-m-d');//gettime
if($this->lastWorkTime != $todayDate)
{
//if the date user last worked is different from today's date, then it means he hasn't worked today yet!
return true;//say he can work by returning true
}
else
{
//if the condition above doesn't apply, we will say he can't work, by returning false
return false;
}
//function to update last time working on the database
public function updateWorkingDate()
{
$mysidia = Registry::get("mysidia");
$dateTime = new DateTime;
$todayDate = $dateTime->format('Y-m-d');//gettime
if($this->lastWorkTime != $todayDate)
{
$this->lastWorkTime = $todayDate;
$mysidia->db->update("users",array("lastWorkTime" => $this->lastWorkTime),"uid = {$this->uid}");
}
}
And then on the page we were working on previously, jobsview.php.
//form,button,text...here
if($mysidia->input->post("submit"))//if button submits
{
if($mysidia->user->canWork())
{
$money = rand(minimumValue,maximumValue);
$mysidia->user->changecash($money);
$mysidia->user->updateWorkingDate();
}
}
Skaiya
04-01-2014, 04:27 PM
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.
Skaiya
04-01-2014, 06:53 PM
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.
squiggler
04-03-2014, 01:38 PM
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.
Skaiya
04-03-2014, 04:02 PM
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.
I had people complaining that they were clicking it too much and not noticing it only gave money once, even though I said so on the page.
squiggler
04-03-2014, 04:42 PM
Maybe add a blurb to the else clause?
You have already claimed your daily paycheck. Come back tomorrow for another!
Zyraph
04-03-2014, 05:09 PM
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
IntoRain
04-03-2014, 06:30 PM
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/1594952/jquery-disable-enable-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:
if($mysidia->input->post("submit"))//if button submits
{
if($mysidia->user->canWork())
{
...
}
else{
//they can't work, put a message here?
}
}
else//before user clicks button
{
//whatever text and button you had outside here
}
OR Putting a return inside the outside if, for when the button submits, also cancels anything that happens after it:
if($mysidia->input->post("submit"))//if button submits
{
if($mysidia->user->canWork())
{
...
}
else{
//they can't work, put a message here?
}
return;//this ends the function, nothing after this will make it to the page
}
//rest of the text and button you had
squiggler
04-04-2014, 01:46 PM
IntoRain, is there a way to set it to specific times? Either a time period (ex: April only) or very specific dates (ex: April 5th)?
IntoRain
04-04-2014, 03:40 PM
In the canWork() function, instead of working with the last time user worked, you'd compare today's date to the date you wanted.
//get today's date, format returns the date in the specified format. m means month and d is day. So 'm-d' means 'month-day' format
$dateToday = new DateTime;
$dateTime = $dateToday->format('m');//get the month only for example
//compare with the month we want
if($dateTime != '04')
{
//it's not april yet, can't work
}
else{
//it's april, can work
}
//or for month-day
$dateToday = new DateTime;
$dateTime = $dateToday->format('m-d');//get the month only for example
//compare with the month we want
if($dateTime != '04-15')
{
//it's not april 15 yet, can't work
}
else{
//it's april 15, can work
}
Hall of Famer
04-05-2014, 04:38 AM
umm a job system, its actually a very interesting idea I must say. I used to think about it in my head before, but its quite difficult to visualize how you can 'work' in an virtual world compared to real world where you just submit your resume and get a job offer. Staff can be programmed to earn wages on weekly or monthly basis, but for most members it's still hard to figure out what kind of jobs they can do.
MikiHeart
04-05-2014, 05:07 AM
For an example on a type of "Job" Mod, see Zarath's Job Mod for Phpbb2.
I think the Job feature is best suited for quests. Like on Neopets, where they have fairy quests, and they go get the item they need, which they give and get a reward.
IntoRain
04-05-2014, 08:27 AM
On 1.3.3 I was doing a job mod that was more like a class system, different jobs would get adoptable-related advantages and could then earn money by selling their adoptables or items created/made in a market, in their own shop.
I think here the idea is to have multiple descriptions of things that need to be done (like "This room is a mess, help me sort it out?" or "Can you bring me some flowers?", so like Miki said, quest-like stuff that might ask for items or not
squiggler
04-07-2014, 12:33 AM
Thank you IntoRain! Oh, that's a great idea HOF! It would be great not to have to manually dispense wages for staff.
Hall of Famer
04-07-2014, 03:56 PM
Thanks Squiggler. I like the idea of automatically generating wages for staff, but the issue is that most people are still 'unemployed', how are they supposed to make money. The best solution is when an exploration system becomes available with a quest-like feature that users can post or accept quests/jobs to earn money. It will take a long time for the script to get there though, as the exploration system is planned for Mys v1.6.0. Before that, the battle system needs to be there.
IntoRain
04-07-2014, 04:14 PM
Thanks Squiggler. I like the idea of automatically generating wages for staff, but the issue is that most people are still 'unemployed', how are they supposed to make money. The best solution is when an exploration system becomes available with a quest-like feature that users can post or accept quests/jobs to earn money. It will take a long time for the script to get there though, as the exploration system is planned for Mys v1.6.0. Before that, the battle system needs to be there.
On the system I was building, there were Alchemists, Merchants and Breeders (only the alchemists and merchants were functional). They would make money out of selling their goods (goods their class could create) instead of receiving consistent money (I didn't actually remember about that, but they could as well maybe?). But building a job system like that is more site-related and maybe not everyone would want it, I was just doing it out of curiosity. So staff and normal members had jobs.
The quest system would work out better like you said, and it's quite an interesting feature I wouldn't mind helping out with if you need a hand!
Kyttias
04-07-2014, 05:52 PM
I think what people want is like 'daily job quests' when your task is to, like... find a specific but random item for an NPC and exchange it for a reward beyond that of the normal sell-back rate. Or just show up and get a free item/amount of currency. Or talk to three other NPCs for another NPC. Pass out fictional deliveries to fictional characters.
I would definitely like to see a full out quest system, but perhaps the focus should be more on making it a mod rather than part of the framework itself.
tahbikat
04-07-2014, 07:54 PM
I think what people want is like 'daily job quests' when your task is to, like... find a specific but random item for an NPC and exchange it for a reward beyond that of the normal sell-back rate. Or just show up and get a free item/amount of currency. Or talk to three other NPCs for another NPC. Pass out fictional deliveries to fictional characters.
I would definitely like to see a full out quest system, but perhaps the focus should be more on making it a mod rather than part of the framework itself.
This. This right here. I think I suggested this in the Suggestions but I don't remember.
That's what I'd love for my site! A simple daily quest feature exactly how you explained it! A member would go to the Quests page, and an NPC would give them a daily quest randomly picked from a list or something that day.
"Bring me 10 worms, 2 grasshoppers, and a fishing line." If the person has it in their inventory, they can click a button that says Complete Quest and get EXP and Moneys! c: Maybe certain quests give an adoptable or a rare item.
Zyraph
04-07-2014, 10:21 PM
I love this idea, and a basic one would work very well for the short term, and as a mod. A more official one can eventually either substitute that entirely or just be an optional thing that someone can hit a button for in the framework.
As for a mod, this could probably reasonably happen before 1.4, and can be expended a little bit after 1.4 hits, and then HoF could take that code and save it to expand upon in later versions, if everyone is comfortable with it. In fact, there could be two versions of it: One being the basic one without too much of a class system, and a more advanced version that can expand upon that for 1.6. I think it'd be very interesting to have the ability to have an option for either/or (or neither, should someone not wish to use them in their version).
Just my thoughts though :3
MikiHeart
04-08-2014, 01:03 AM
This. This right here. I think I suggested this in the Suggestions but I don't remember.
That's what I'd love for my site! A simple daily quest feature exactly how you explained it! A member would go to the Quests page, and an NPC would give them a daily quest randomly picked from a list or something that day.
"Bring me 10 worms, 2 grasshoppers, and a fishing line." If the person has it in their inventory, they can click a button that says Complete Quest and get EXP and Moneys! c: Maybe certain quests give an adoptable or a rare item.
To do a simple version of this is actually pretty easy. The hardest part I can think of is being the ability to create new quests in the admin panel. But if you wanted to start simply, you could hard code the quests and build upon it later on.
squiggler
04-08-2014, 01:10 PM
I don't know...I've never been a fan of alchemy quests. I prefer quests where you get through the forest to get the sparkly whosit. Maybe collect the pieces, but that doesn't count as alchemy to me? Anyway, I mention in case someone does the mod.
IntoRain
04-08-2014, 02:09 PM
To make a generic quest-creator the different types of quest would have to be coded in. Visiting some place to get X or talking to an NPC would demand an exploration system I think, that's a bit complicated to code, at least a bit hard to think about in php terms.
But quests like get certains items or obtain an adoptable of this species at level 50, are possible to generalize (any more ideas?) and I will try to tackle this next week, if I have the time.
tahbikat
04-08-2014, 04:51 PM
To make a generic quest-creator the different types of quest would have to be coded in. Visiting some place to get X or talking to an NPC would demand an exploration system I think, that's a bit complicated to code, at least a bit hard to think about in php terms.
But quests like get certains items or obtain an adoptable of this species at level 50, are possible to generalize (any more ideas?) and I will try to tackle this next week, if I have the time.
What about riddles, questions, etc? Would those be easy or hard?
For example, I visit the Daily Quest page for today and today's "quest" is a question. The NPC asks "What creature has a mushroom growing from its back?" I'd input into the text field the answer, and if right I get the reward, if wrong, the page displays "Oops, wrong answer! Try again?" Same with riddles.
There could even be smaller "quests" the NPC could give. Letter Mixes, Word Opposites, Fill in the blank letters, etc.
Some examples:
Letter Mix awards 50 coins
Use these letters to spell out a word or name.
TCA RWEOFL
= Flower Cat
Word Opposites awards 50 coins
Think of the opposite of each word for the correct answer.
DIRTY LAND
= Clean Sky (idk? lol i suck at this)
Fill the Blank awards an item (potion)
Fill in the blank spaces with letters to spell out a word.
P _ T I _ N
= Potion
Some of these would award adoptables, items, etc depending on how difficult they are.
squiggler
04-09-2014, 04:36 AM
Brilliant tahbikat! With a limited number of tries, too, so they can't guess forever.
If I can think of any myself (no luck right now XD ) I'll post later.
IntoRain
04-20-2014, 06:24 PM
Just wanted to say I started work on this already, so I'm still taking suggestions
- Currently quests can be a question (you can write whatever you want so word plays can be done as well), asking for items and/or asking for money. Rewards are items, money and/or adoptable. I also wanted a quest to ask for an adoptable but that's taking long
- One quest is generated per day per user, user can't change it until the next day even if he can't complete it - it's easier to implement this way than to have a limit for each quest :(
- ACP integration is missing
squiggler
04-22-2014, 12:46 AM
Okay, here is the question wall:
How much text can we add to the questions, with what BBcode/HTML, and is there a way to add permanent text to the thing? (Like, "You will be offered 1 new quest per day.") For that matter, can users keep their quest past 24 hours? Also, can we admins have multiple quests available with different chances of getting each quest?
IntoRain
04-22-2014, 05:21 AM
Okay, here is the question wall:
How much text can we add to the questions, with what BBcode/HTML, and is there a way to add permanent text to the thing? (Like, "You will be offered 1 new quest per day.") For that matter, can users keep their quest past 24 hours? Also, can we admins have multiple quests available with different chances of getting each quest?
The text length is set in the database, I put it at 200 characters, but it can be changed if needed. HTML can be inserted. The quest's specific information will display on a page, so you can write fixed text on that page as well
Users get a new quest once per day, even if they didin't complete it. If they complete it, they can't get a new one until the next day as well
Not sure if I will add different chances of getting a quest, possibly after this part is done xD
squiggler
04-22-2014, 03:35 PM
Thank you! That's awesome!
But can users have 2 quests going at one time, or do quests permanently disappear after 1 day?
If we can input multiple quests, there is a workaround. For example, say you have 4 quests, A, B, C, and D. Instead of inputting just 4 quests, you put in 10:
A
B
B
C
C
C
D
D
D
D
Now A has a 10% chance, B has a 20% chance, C a 30% chance, and D a 40% chance. It looks a little silly in the ACP, but the users will never know the difference.
This might mess up any badges they can get for completing quests, if you put that in, though.
Anyway, thank you for starting this awesome mod!
IntoRain
04-23-2014, 04:38 AM
Thank you! That's awesome!
But can users have 2 quests going at one time, or do quests permanently disappear after 1 day?
If we can input multiple quests, there is a workaround. For example, say you have 4 quests, A, B, C, and D. Instead of inputting just 4 quests, you put in 10:
A
B
B
C
C
C
D
D
D
D
Now A has a 10% chance, B has a 20% chance, C a 30% chance, and D a 40% chance. It looks a little silly in the ACP, but the users will never know the difference.
This might mess up any badges they can get for completing quests, if you put that in, though.
Anyway, thank you for starting this awesome mod!
They permanently disappear, they can only keep 1 per day.
Yeah that is possible but it would be quite tiring for both the admins and the database xD I will try to add chances to it
edit: the host I'm using for my test site is migrating, it's been hard to test anything the last few days so I gave up until finish the move, that's why nothing has been released yet :(
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.