Keep contdown timer running even if the game was close

Hello guys,

Before anything else, I would like to apologize for my bad english, I’m from Brazil.

I’m making a game for Mobile, and would like to make a countdown timer.
Used to upgrade a weapon for example. (Okay, easy)

The problem is, my game will be offline and I wish to keep this countdown timer running even if the game was close.

is there any easy way to do this?
If there was a way to get the schedule of the operating system.
this has help me a lot.
(although this could be easily cheated)

Yes: Instead of storing “there’s 20 seconds left,” store “this upgrade will be available at time XX:XX GMT.”

Then, when you display how much time is left, subtract from the target time, to see how much is left. If it’s after that time in GMT, then the upgrade is available.

This needs access to a real clock that’s set correctly, of course. Typically, this comes from servers, but if it’s single player, you can use the normal PC clock. You might want to double-check that the clock doesn’t jump around too much – daylight savings time, leap seconds, CMOS batter replacement, and a bunch of other things may do weird things to time.

Get Accurate Real Time solve my problem !

This function returns the current time of the OS in seconds !
so i can compare the time when the player left the game with the time he joined.

Be aware cheating will be as easy as setting the time then though :wink:

Presumably, anything important for gameplay is actually done server-side. The timer should only be set when the player requests it AND the server determines that preconditions are met (pay resources, etc.) Also, while the client-side GUI can show “X minutes left,” the actual “create the upgraded unit” effect should only happen on the server, or at least should only happen after the server has agreed that it’s correct and updated the state according to the enforced game rules.
Someone setting the “time when done” value locally will then see an inaccurate “X minutes left” display, but should not be able to cheat the server.