Tokio

[HELP] How to save table datas?

Recommended Posts

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 

Share this post


Link to post

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 by Geteco

Share this post


Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.