Killerhamster10 Posted May 11, 2010 Posted May 11, 2010 Hey, I'm working on buymap script and want to do this with xml. So i created this script: addEvent("onMapStarting") addEventHandler('onMapStarting', getRootElement(), function() local mapName = getMapName() if mapName and mapName ~= "None" then saveMapData ("MapName",getMapName()) end end ) function loadMapData (player,datatype) local mapName = getMapName() if mapName and mapName ~= "None" then local root = xmlLoadFile ("maps.xml") if (root) then local MapsNode = xmlFindChild (root,"map",0) if (MapsNode) then local MapRootNode = xmlFindChild (MapNode,"MAP_" .. getMapName() .. "||",0) if not (MapRootNode == false) then local MapData = xmlNodeGetAttribute (MapRootNode,datatype) if (MapData) then xmlUnloadFile (root) return MapData else xmlNodeSetAttribute (MapRootNode,datatype,0) xmlSaveFile (root) xmlUnloadFile (root) return 0 end else local MapRootNode = xmlCreateChild (MapNode,"MAP_" .. getMapName().. "||") xmlNodeSetAttribute (MapRootNode,datatype,0) xmlSaveFile (root) xmlUnloadFile (root) return 0 end end end end end function saveMapData (datatype,newvalue) local mapName = getMapName() if mapName and mapName ~= "None" then local root = xmlLoadFile ("maps.xml") if (root) then local MapNode = xmlFindChild (root,"map",0) if (MapNode) then local MapRootNode = xmlFindChild (MapNode,"MAP_" .. getMapName().. "||",0) if not (MapRootNode == false) then local newNodeValue = xmlNodeSetAttribute (MapRootNode,datatype,newvalue) xmlSaveFile (root) xmlUnloadFile (root) return newNodeValue else local MapRootNode = xmlCreateChild (MapNode,"MAP_" .. getMapName().. "||") local newNodeValue = xmlNodeSetAttribute (MapRootNode,datatype,newvalue) xmlSaveFile (root) xmlUnloadFile (root) return newNodeValue end end end end end I don't get any error but it doesn't save the map everytime. That means, when i have the empty xml and start the script and a map, it saves it in the xml. But when i change the map, it doesn't save it... Can someone help me? Greetings
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