Saving data for use after reboot?

I’m not really sure how to save data. I’m thinking about using file.Write, file.Read and some quick and dirty string manipulation technique. Is there a better way?

Writing to nonvolatile memory is the way to save data through a reboot. Using a JSON object for data storage is preferable, though.

Write the JSON to a file, do your restart, and make sure you’re “safely” opening your file and parsing it when you get back. (By safely, I mean handling conditions for file doesn’t exist, can’t be read, etc.)

Alternatively, if you need to access this data regularly, you could use a SQL to access it.

hm, I’ll look into that, although I don’t know anything JSON or ‘nonvolatile memory’. Thanks for the tip.

JSON is a standardized object format, primarily used in JavaScript.

Nonvolatile memory is any memory that doesn’t have its data get erased when it loses power. i.e. your hard drive (saving to file)

non volatile means just any memory that isn’t erased when you power down.

JSON is easy too: http://www.copterlabs.com/blog/json-what-it-is-how-it-works-how-to-use-it/

I took this off the wikipedia. What does this mean? You can store memory while there is no power? :pwn:


non-volatile storage is computer memory that can get back stored information even when not powered.

haha

Alright thanks. What was I thinking lol.

[editline]5th November 2013[/editline]

So how would I implement this into garrysmod? Javascript != Lua. A little confused.

To use JSON in gmod you would use

and

You can use the local SQL database that ships with garry’smod.
You can use PDATA on players to store information on each player object or access the query functions directly to store other information.