Delta time (Daily Reward, unlock countdown...)

Hi there!

I’m working on real-time based features for my Android game.

For example, the player can buy an item, and 8 hours later the item will be delivered to his mailbox.

So when the player buys his item, I store the actual “Date Time”.

Then, when the player opens his mailbox to see if he received the item, I try to compare the Date Time of the item with the current date time, in order to let him access his reward or not, by doing this:

This only works if the minutes / hours / days / … ​​do not exceed their maximum realistic values.

Let me explain: if the player buys his item at 15h00, he will receive it at 23h00. The code works in this case.

But if he buys it at 17h00, he will be supposed to receive it at 25h00, which is not possible, because the node don’t understand what to do with this “25”.

Is there an easy way to do this, or should I do something like “if it’s over 24 hours, then compare the day, if it’s over 31, then compare the month, if…”?

ps: It’s an offline game, so I don’t care if the player changes the clock on his phone to cheat.

Thanks a lot!

Likely it’s the compare operator not functioning as expected, try “greater than” instead of “greater than or equal to” and see if that fixes it

Okay I found a solution, I was trying to do maths for no reason x)

1 Like

Nice!