Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Can we let a time counter working even if an app is closed? I would like to add a timer so that we have to wait XX seconds/minutes before a building is created in a game.

I don't want to use an internet connection, and if the user closes the app and just changes the time on his mobile, I cannot compare the 2 time values - before and after.

Would you know how to do this?

Thanks

share|improve this question
    
possible duplicate of Strategies to Defeat Memory Editors for Cheating - Desktop Games –  Anko Jul 18 '13 at 14:16

3 Answers 3

up vote 0 down vote accepted

Timestamp modification is a type of memory-modification cheating, as asked here. The solution is the same:

Is your game multi-player?

If yes, keep an authoritative timestamp on the game server that you already have.
If no, where's the problem? Your players are only cheating themselves.

share|improve this answer
    
it is not multi-player, I am trying to avoid having some players beating the leaderboards by 1000% in some hours, when other could take a week to get the same result :) –  Paul Jul 18 '13 at 14:51
    
Ah, the terminology gets my way! :D It's the same idea: Multiple players are interacting by competing on a leaderboard. As long as some such interaction exists, players might cheat others. Your options are security by obscurity (but here's why not) or keeping a copy you know is correct. –  Anko Jul 18 '13 at 15:53
    
Thanks Anko for the answer –  Paul Jul 19 '13 at 13:15
    
I'm not sure the player would be modifying any timestamps in this situation. It's the actual device clock that's changing, nothing in-memory with the game. (Which is why I also don't think this is a duplicate of the memory editor question, not only because that one has to do with desktop games). –  Byte56 Jul 19 '13 at 13:45
1  
For example, one strategy for preventing memory editing would be multiple copies of the value, or multiple data types representing the same data. This wouldn't work in this situation because there's nowhere to get an accurate value to begin with. This question is essentially "How do I trust the client, when the client is the only source for this value?". Of course the answer is, you can't. –  Byte56 Jul 19 '13 at 15:29

If you're wanting to ensure the time is accurate, you should get the time from the internet or from the GPS on the device.

If the user closes the app, there is nothing left to run a timer with. Even services are paired with a process and will get cleaned up if not being used.

You can detect time changes when your app is running, but your app won't know what happened while it wasn't running.

Here's a strategy that may work. It does involve using the internet, but it limits the usage to times when the user should likely have a connection. This avoids the player not being able to play when there's no connection.

  1. When the game is installed, connect to the internet and get the time you want to use, along with the device time.
  2. Every time a building is built, record a timestamp to the file system. (If a connection is available, get the time from the internet to verify).
  3. When/if the player submits their score the leaderboard, connect to the internet again and get the time you want to use. Ensure that all the buildings were built between the current time and the last valid time you have recorded. If it's impossible for the player to have built that many buildings in that time frame, invalidate the score.

It doesn't detect every case, but it should help a little.

share|improve this answer
    
Ah, the silent downvote, what could be less useful? –  Byte56 Jul 19 '13 at 13:05
    
Hi Byte56, sorry it was me, it's because that I read that solution with internet and the file in the other answers, and I would prefer not to use internet, and avoid the issue with changing the clock as I said in my post. But nothing personal, I put the +1 back for your answer. (edit: as soon as I can ;) it's locked now) –  Paul Jul 19 '13 at 13:14
    
I know it's nothing personal Paul. It's just nice to have a reason so I can make it a better answer! I've tried to do just that. –  Byte56 Jul 19 '13 at 13:21
    
Thanks Byte56 for the answer –  Paul Jul 20 '13 at 5:37

can you not just log something in a file or something that says "pending event at time X". Then when the game is next loaded do the required "add building" if the time is passed?

Failing that, if the game is server based surely all that happens is when the game is next loaded the change is picked up because the server already did it.

It's more a case of ... Is the game running or not? If it is, then it likely has a UI, if it isn't then me as a user, i don't want that game doing stuff i'm not expecting. Seems suspicious when devs try to this sort of stuff.

share|improve this answer
    
"if the time is passed" If I check the time when he comes back, the user could just change his own clock on his mobile I guess? –  Paul Jul 18 '13 at 14:47
    
i guess it depends if this "time based event" is critical / likely to result in some sort of exploit ... most people code their games in such a way that they effectively pause when unloaded. –  Wardy Jul 19 '13 at 19:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.