Changing time on device => cheating in the game

北城以北 提交于 2019-12-24 13:59:28

问题


In some games people can cheat by changing the time. For example: when they have to wait 30 minutes before a building is built. Can i prevent this, assuming that the devices have connection with my server? I am programming in java using the libGDX library. Any solutions that work both on IOS and Android?


回答1:


Store the time they have to wait to on the server (tell the server they perform a task, server will log that time and when they can do it again) and make the client check if the server thinks it can in fact perform the action. Anytime you store something on the client it is likely that there will be a way around it.




回答2:


Your best bet would be to use SystemClock.elapsedRealtime() as an assistant to an infrequent server side timecheck.

return the time since the system was booted, and include deep sleep. This clock is guaranteed to be monotonic, and continues to tick even when the CPU is in power saving modes, so is the recommend basis for general purpose interval timing.

After verifying the time from your server, you can do local checks against SystemClock.elapsedRealtime until the next boot up.



来源:https://stackoverflow.com/questions/20906589/changing-time-on-device-cheating-in-the-game

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!