Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 04-01-2014, 10:24 AM
Skaiya Skaiya is offline
Member
 
Join Date: Mar 2014
Location: Netherlands
Posts: 40
Gender: Female
Credits: 7,274
Skaiya is on a distinguished road
Default 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.
__________________

Last edited by Skaiya; 04-01-2014 at 10:32 AM.
Reply With Quote
  #2  
Old 04-01-2014, 03:02 PM
squiggler's Avatar
squiggler squiggler is offline
Squiggling since 1995
 
Join Date: Jul 2013
Posts: 185
Gender: Unknown/Other
Credits: 8,207
squiggler is on a distinguished road
Default

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.
__________________
Avatar courtesy of Doll Divine.
Reply With Quote
  #3  
Old 04-01-2014, 03:17 PM
IntoRain's Avatar
IntoRain IntoRain is offline
Moderator
 
Join Date: Jul 2013
Location: Portugal
Posts: 461
Gender: Female
Credits: 19,382
IntoRain is on a distinguished road
Default

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

PHP Code:
$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:
PHP Code:
$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:

PHP Code:
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!

PHP Code:
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:

PHP Code:
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.

PHP Code:
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.

PHP Code:
//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();
     }

__________________


asp.net stole my soul.
Reply With Quote
  #4  
Old 04-01-2014, 04:27 PM
Skaiya Skaiya is offline
Member
 
Join Date: Mar 2014
Location: Netherlands
Posts: 40
Gender: Female
Credits: 7,274
Skaiya is on a distinguished road
Default

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.
__________________

Last edited by Skaiya; 04-02-2014 at 03:19 AM.
Reply With Quote
  #5  
Old 04-01-2014, 06:53 PM
Skaiya Skaiya is offline
Member
 
Join Date: Mar 2014
Location: Netherlands
Posts: 40
Gender: Female
Credits: 7,274
Skaiya is on a distinguished road
Default

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.
__________________

Last edited by Skaiya; 04-02-2014 at 04:21 AM.
Reply With Quote
  #6  
Old 04-03-2014, 01:38 PM
squiggler's Avatar
squiggler squiggler is offline
Squiggling since 1995
 
Join Date: Jul 2013
Posts: 185
Gender: Unknown/Other
Credits: 8,207
squiggler is on a distinguished road
Default

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.
__________________
Avatar courtesy of Doll Divine.
Reply With Quote
  #7  
Old 04-03-2014, 04:02 PM
Skaiya Skaiya is offline
Member
 
Join Date: Mar 2014
Location: Netherlands
Posts: 40
Gender: Female
Credits: 7,274
Skaiya is on a distinguished road
Default

Quote:
Originally Posted by squiggler View Post
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.
__________________
Reply With Quote
  #8  
Old 04-03-2014, 04:42 PM
squiggler's Avatar
squiggler squiggler is offline
Squiggling since 1995
 
Join Date: Jul 2013
Posts: 185
Gender: Unknown/Other
Credits: 8,207
squiggler is on a distinguished road
Default

Maybe add a blurb to the else clause?
You have already claimed your daily paycheck. Come back tomorrow for another!
__________________
Avatar courtesy of Doll Divine.
Reply With Quote
  #9  
Old 04-03-2014, 05:09 PM
Zyraph Zyraph is offline
Member
 
Join Date: Mar 2014
Location: Indianapolis, IN
Posts: 36
Gender: Male
Credits: 4,335
Zyraph is on a distinguished road
Default

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
Reply With Quote
  #10  
Old 04-03-2014, 06:30 PM
IntoRain's Avatar
IntoRain IntoRain is offline
Moderator
 
Join Date: Jul 2013
Location: Portugal
Posts: 461
Gender: Female
Credits: 19,382
IntoRain is on a distinguished road
Default

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:
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:

PHP Code:
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 
__________________


asp.net stole my soul.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Javascript Games to Give Users Currency Hwona Questions and Supports 2 12-13-2015 05:01 AM
How to earn money on site? O.o Rovick Questions and Supports 2 06-29-2014 03:31 AM
Page that gives users money Derpstra Tutorials and Tips 0 08-18-2012 11:34 AM
Change earn money jcga1992 Questions and Supports 1 04-24-2012 10:39 AM
Earn Random Amounts of Money Rissan Suggestions and Feature Requests 2 08-25-2011 09:51 PM


All times are GMT -5. The time now is 01:44 PM.

Currently Active Users: 9734 (0 members and 9734 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636