StefanAlmighty Posted November 27, 2015 Share Posted November 27, 2015 Hi, so I've created a very basic script which loads text into a GUI Memo from XML. I'm working on making it so in-game admins are able to edit the text in-game and make it save back to the XML. However my issue is the following: Everything works, except when the resource is restarted, the XML loads the old text and not what has been edited before the restart. I'm assuming it's not saving properly to the XML file. Here is my code which saves it: local function updateContent(theTab) xmlFile, theText = nil, nil if theTab == tabRules then xmlFile = xmlLoadFile( "rules.xml" ) theText = guiGetText(memoRules) elseif theTab == tabAdmins then xmlFile = xmlLoadFile("admins.xml") theText = guiGetText(memoAdmins) elseif theTab == tabScripts then xmlFile = xmlLoadFile("scripts.xml") theText = guiGetText(memoScripts) else outputChatBox("Error 02") return false end xmlNodeSetValue(xmlFile, theText) xmlSaveFile(xmlFile) --Save the xml from memory for use next time xmlUnloadFile(xmlFile) --Unload the xml from memory outputChatBox("Saved.") end addEventHandler ("onClientGUIClick", root, function () if source == buttonRules then updateContent(tabRules) elseif source == buttonAdmins then updateContent(tabAdmins) elseif source == buttonScripts then updateContent(tabScripts) end end) function ClientResourceStop () xmlSaveFile(xmlFile) --Save the xml from memory for use next time xmlUnloadFile(xmlFile) --Unload the xml from memory end addEventHandler ("onClientResourceStop", resourceRoot, ClientResourceStop ) Link to comment
ALw7sH Posted November 27, 2015 Share Posted November 27, 2015 It could be something with the permission, is the xml files being created by the script ? Edit: Where are you loading your text into the xml file? Link to comment
TAPL Posted November 27, 2015 Share Posted November 27, 2015 You should make the xml file server side. 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