Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by worldofcars · Apr 09, 2012 at 04:28 PM · money

Give a player gifts if he plays the game every day... how?

Hallo. How can I give a gift to a player, who play the game regurarly, like for each day he plays, he get 1000 monay. How to do that ?;)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Kleptomaniac · Apr 09, 2012 at 04:51 PM

Use System.DateTime.Now. So for example, just before a game session ends, insert this:

 var lastDay : int = System.DateTime.Now.get_Day();

And then, when a player relogs back in, in your Start () function, check whether it's been less than a day since they were last on:

 function Start () {
     if (System.DateTime.Now.get_Day() - lastDay == 1) {
         Debug.Log("Have lotsa money!");
     }
 }

That should work. :)

Hope that helps, Klep

Comment
Add comment · Show 10 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image worldofcars · Apr 10, 2012 at 01:34 PM 0
Share

GREAT! It works :) Thank you

avatar image Kleptomaniac · Apr 10, 2012 at 01:57 PM 0
Share

No worries! Glad I could help.

avatar image worldofcars · Apr 10, 2012 at 02:00 PM 0
Share

Now I need help here :) : http://answers.unity3d.com/questions/237950/give-the-player-every-day-an-other-gift-but-random.html

avatar image Rustamovich · Nov 03, 2014 at 09:32 AM 0
Share

you said " just before a game session ends, insert this:" which function need to be used? is "onDisable" enough?

avatar image SteveBC · Nov 03, 2014 at 09:46 AM 0
Share

Your best bet would be to set lastDay in OnApplicationQuit() in a script with DontDestroyOnLoad, just to be sure.

Also, you'll want to probably save your lastDay integer in your PlayerPrefs and fetch the value at game start, so the value doesn't reset every time the game starts.

Show more comments
avatar image
0

Answer by NothAU · Apr 09, 2012 at 09:10 PM

Perhaps a couple of variables, one to track if the player has played today, and another to track the number of days in a row they play.

From there, it's just a matter of getting the system time/date, loading, updating, and saving it on launch, and an if statement to to check if the player has met your criteria, and award the gift.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Placing objects in TD Game 1 Answer

GetComponent Help 1 Answer

Revenue exceeds personal limit 1 Answer

Need help with PlayerPrefs 2 Answers

Making money with Unity 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges