question

austerepeasant avatar image
austerepeasant asked

Offline Progression Buff

I have a game that is only saved when online. I want to offer players a 'progress buff' in exchange for the time they were offline. So my question is this:

What is the best way to count the amount of time they were 'offline'? Since the game saves data very frequently while online I can combine data calls. So basically it would be the time between the last time data was saved and the time of the current login.

The only way I can see how to do it is use the 'GetTime' call before I save data and then 'save' the current time as a variable, then load that variable next time the player logs in and compare values with a fresh 'GetTime' call.

Is there a better way to do this?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Actually, unless you're using a custom game server (and so, have a persistent socket connection to the client), the way this should work is that as you progress the game locally, you periodically attempt to update the service - every couple of minutes or so, but with priority updates when something key happens in the game flow, like a boss fight, etc.

In order to save battery on a user's device (if this is for a mobile game), you should have an exponential backoff on attempt to hit the service, so that when they're unable to get a connection, you're not chewing through their charge.

But yes, the best practice then is to use Cloud Script (or a custom game server) to do some checks of the data sent by the client (how long since the last update, are the values reasonable for that elapsed period, etc.) before committing it to the online save.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

austerepeasant avatar image austerepeasant commented ·

So... GetTime is what I want to use? Or is there a way to track when the last saveuserdata event occured?

0 Likes 0 ·
brendan avatar image brendan austerepeasant commented ·

Both - you'd use GetTime to get the current time, and there's a timestamp you get back on the user data to let you know when it was last updated.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.