3
\$\begingroup\$

Im making an old school arcade for android where you have to get the highest score between levels. At each level you can save the progress. If you die and have 0 lives left your save file gets deleted. However to prevent cheating I want the game to erase the save file when the player quits the game mid level instead of going back to the last save. What is the code for checking if the player force closed the game?

\$\endgroup\$
  • \$\begingroup\$ When you save the high score, is it only locally saved or in a public table? If it's only stored locally, does it really matter if someone cheats? Games (especially offline ones) are like tools to have fun. If the user has fun cheating in these games, why stop them? \$\endgroup\$ – TomTsagk Sep 27 '19 at 9:56
  • \$\begingroup\$ I just hope your game runs very, very stable. When your game is prone to crashing, players will really hate you for this. I wouldn't know a way to tell the difference between a crash and the player killing the game task. \$\endgroup\$ – Philipp Oct 28 '19 at 11:46
1
\$\begingroup\$

Only allow saving on quit and delete the save on load.

A somewhat common approach to this sort of problem is to quit the game when you save. So for your case, when they player try to save the game they could be presented with two options:

  1. Save and quit
  2. Cancel

Then when the player returns to the game to load their save you can pop up a warning to the effect of "loading this save will delete it, are you sure you want to continue?"

Note: It should be noted that games with this sort of save system will typically have communities that share how to backup and restore your save in order to bypass this limitation. So while casual players may abide by your save restrictions, people who are actually fans of your game will likely try to circumvent it. As other answers have mentioned, often times it's not worth it to go through fancy hoops to protect offline single player games.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

you cant prevent cheating in a offline game in any system of storage.

if you store it in ram, a hacker can read it and change it. look for trainers that are built.

even if you encrypt the saved or any important data, its possible to read it when its decrypted or before encryption.

if you see that online games cant be cheated because all logic and data is on server and user client only can send inputs.

even if your goal is not cheating, deleting a file and making a new one is not a good practice. you should manipulate contents in the file.

conclusion: for a game that is not still big enough to be valuable for cheating, dont worry about cheating. just make it, you can make it safe when its needed.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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