• Help using data saving system (file.read/file.write)
    3 replies, posted
Hello, I am new to lua and I would appreciate if someone would take the time to explain to me a basic saving system using file.Read/file.Write. I have checked many scripts using this system but they are way too complex for me to really learn from them. Also if you could make me a really simple example such as saving a random number for every player that joins, I would appreciate that as well. But if you think that wont help me feel free to link me to helpful resources. I don't believe I am asking too much but if you feel as if this post is stupid and pointless then please don't waste your time and leave a hateful comment/rate.
Save: [URL="http://wiki.garrysmod.com/page/Category:table"]table[/URL] -> [URL="http://wiki.garrysmod.com/page/util/TableToJSON"]JSON[/URL] -> [URL="http://wiki.garrysmod.com/page/file/Write"]file[/URL] Load: [URL="http://wiki.garrysmod.com/page/file/Read"]file (JSON)[/URL] -> [URL="http://wiki.garrysmod.com/page/util/JSONToTable"]table[/URL]
If you need a random number for every player that joins, you could just do [CODE] hook.Add( 'PlayerSpawn', 'AssignNumber', function(ply) ply.RandomNumber = math.random(1,9999) --Change this to your own upper and lower limits end) print(LocalPlayer().RandomNumber) > Some number between 1 and 9999 [/CODE] You don't necessarily have to use file.Read and Write for data like that (unless you want to). Also, [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/file/Read]file.Read[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/file/Write]file.Write[/url] are explained pretty well in the links right there.
I'd suggest learning to do mysqloo stuff instead. It's much more effecient and a better use of time.
Sorry, you need to Log In to post a reply to this thread.