How do I save data locally?

Question

So I’m building a survivors-style game for learning and I need to store the count of enemies the player killed in this run locally. Some ways I found to do this are to

  • store the data in JSON format and use it that way.
  • or through a config file.
  1. But my concern is that if I store the data like this, can’t the user directly change the save file as everything is in plain text and the data can be edited easily? Is this the correct and recommended way to do it?
  2. The other concern I have is that the users can share the save files with each other. So if user A has unlocked some stuff in the game, and user B has just started, user A can share the save file with user B and user B will have the same progress as user A. Is this supposed to be normal? Should I ignore it or are there ways to handle this?

Any help is appreciated.

Hi,

For single-player games it’s pretty normal that you can do stuff like transfer save files to another computer, and sometimes even edit them. If it’s a single player game, you aren’t ruining anyone else’s experience, so if someone thinks it’s fun to give themselves a fake high score or whatever, who cares? Most people enjoy engaging with the game more than they enjoy editing save files anyway.

If you want to make it harder to edit save files, you can serialize it to some binary format - no one says it has to be JSON, you can save and load any file in GDScript (or C# if you’re using that), though depending on what format you want, you might need to write your own parser for it… But consider if it’s worth it for your project.

For multiplayer games, again it depends: How is it expected to be played, and how much are you ruining other people’s experiences if you cheat? If it’s a competitive game, or an MMO where it matters that resources go to those who fairly earned them or traded for them, then all actions will generally go through a server, which validates that the action is possible, and the server will keep track of who owns what resources. On the other hand, for coop games that are typically played with a few friends where one of the players hosts the game, sometimes the save file will just be stored locally on the host’s computer. Again, if a small group of friends decide that they wanna mess with their save file and give themselves more resources or whatever, who cares? They’re having fun and harming nobody.

1 Like

Thank you. I’ll need to get comfortable with this I guess :sweat_smile: