daily bonus

1 favourites
  • 13 posts
From the Asset Store
This is a source code sale for the game "Mega Bonus 777 Casino Game Html5"
  • hi, how to make a user get a bonus every day he opens the game?

    what do I need to do that?

  • You can use floor(unixtime/86400) to get the day number.

    Then use local storage to keep track if the user has received the reward for the day or not.

  • thx for reply, its need a plugin?

  • No they are both built in.

  • You can use floor(unixtime/86400) to get the day number.

    Then use local storage to keep track if the user has received the reward for the day or not.

    oosyrag

    Hi, please can you explain what floor(unixtime/86400) is doing? on project its give me the 18195168...

  • 86400 represents a day

  • 86400 represents a day

    and whats 18195168 represents? i got that value using that

  • That's the current day number in unix time. Tomorrow would be 18195169, and the day after would be 18195170.

    You keep track of that number to see if the user has logged in or claimed a reward for that day. When that number changes, it represents a new day.

  • oosyrag

    Thanks, so this check something like the day on the device? if the user change the day on the device, to claim more reward, this unix time will not change right?

  • Unfortunately no, the system time is used to calculate Unix time. Unix time is good so you don't have to worry about things like time zones, different numbers of days per month, or leap years.

    To get a device independent time, you'll need to connect to an online service or server with a time API. Sorry can't help with that.

    There are some tricks you can utilize to limit cheating like a limit to how many days worth of rewards can be stored at a time, and also the inability to go "back" in time. For example, you can lock out the user or freeze the rewards if the day counter is ever less than whatever was last recorded or claimed. You can also do things like have the reward only apply from that day forward. This would require the user to keep their device with they the wrong day/time, which I think most people would not want to do.

    In the end, the best advice in my opinion is not to worry about cheaters too much when designing your game. Very few people cheat to begin with, and those that do so get enjoyment from it. As long as it's not detrimental to the rest of your users, just let them have fun their own way. You could spend the effort to design your game to be more fun to begin with to disincentivise cheating instead.

    TLDR If the game is online/interactive, you have the ability to check the correct time. If it's not, it doesn't really matter if the user cheats or not.

  • oosyrag

    Thats a really good answer. i will do what you said. Perhaps construct 3 will add a daily reward =(

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • > 86400 represents a day

    and whats 18195168 represents? i got that value using that

    You need to use floor(unixtime / 86400 / 1000)

    because unixtime is milliseconds, not seconds.

    For a daily reward just do this:

    -> create a global variable (number) (I call it "dailytime")

    -> create a Button to collect the daily reward

    -> when clicking the Button you need to compare, if the "dailytime" is less than "unixtime". If YES -> give reward and update "dailytime" to "unixtime + (86400 * 1000)"

    Thats it :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)