Tokio Posted November 17, 2018 Share Posted November 17, 2018 if i create a table, and i insert datas with table.insert, the datas are deleted when i reconnect.. why? how to save datas? sorry for my terrible english :ss Link to comment
Geteco Posted November 17, 2018 Share Posted November 17, 2018 (edited) Can you save through XML. here's an example: function saveTable() local loadFile = xmlLoadFile("save.xml", "root") if not (loadFile) then loadFile = xmlCreateFile("save.xml", "root") end for i, v in ipairs(ourTable) do -- change 'ourTable' to your table name local createChild = xmlCreateChild(loadFile, "vehicle") xmlNodeSetAttribute(createChild, "x", v.x) -- v.x is your table value, just change it xmlNodeSetAttribute(createChild, "y", v.y) xmlNodeSetAttribute(createChild, "z", v.z) end end addCommandHandler("rsave", saveTable) Edited November 17, 2018 by Geteco Link to comment
Gordon_G Posted November 17, 2018 Share Posted November 17, 2018 Using toJSON and fromJSON you can convert a table to a string You can save the string in a database, an XML file or even a txt file Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now