Best practice for keeping track of a variable in real-time? (453010)

This question might be better for the scripting forum, but it’s only really relevant for iPhone.

I’ve got a game that wants the player to come back all the time. So there’s a health bar that is always decreasing, say, by 1 point per hour. How would I go about keeping track of time, in real time?

So say the game is turned off overnight, in the morning, they will have 10 less health, or if they leave it for a week they’ll be dead.

any idea’s on how to do this in a stable fashion?

Remember the time they stopped playing and well as their health at that point. Then do a simple calculation to figure out their new health the moment they resume playing.

If you rely on the device’s time data, then this is easily cheated. The most secure way to handle it is by storing the data and calculating the health remotely, on your own server.