Blueman Posted April 9, 2012 Share Posted April 9, 2012 It seems when I execute this code it doesn't save to the xml file like it is intended to. Ranks.xml <Ranks> <gameranks> </gameranks> </Ranks> Meta.xml <meta> <info name="RankSystem" author="Blueman" version="1.0.0" type="script"></info> <script src="Main.lua" type="server"/> <file src="Ranks.xml" /> </meta> Ranks = xmlLoadFile ( "Ranks.xml" ) function createRank(INT, Label) if (INT) and (Label) then local GR = xmlFindChild(Ranks,"gameranks",0) if (xmlFindChild(GR, INT)) then outputDebugSting("That rank has been created already") else xmlNodeSetValue (xmlCreateChild (GR , INT), Label ) xmlSaveFile(Ranks) end else outputDebugString("In function createRank() incorrect arguments") end end Any help would be appreciated. Link to comment
Castillo Posted April 10, 2012 Share Posted April 10, 2012 I'm not sure what are you trying to achieve, but you have a problem there, you can add multiple ranks with the same name. function createRank ( INT, Label ) local Ranks = xmlLoadFile ( "Ranks.xml" ) if ( Ranks ) then if ( INT ) and ( Label ) then local GR = xmlFindChild ( Ranks, "gameranks", 0 ) if ( xmlFindChild ( GR, INT, 0 ) ) then outputDebugString ( "That rank has been created already." ) else xmlNodeSetValue ( xmlCreateChild ( GR , INT ), Label ) xmlSaveFile ( Ranks ) end else outputDebugString ( "In function createRank() incorrect arguments." ) end else outputDebugString ( "In function createRank() invalid XML file." ) end end I've fixed that small error, also you had another problem. You had "outputDebugSting" instead of "outputDebugString". This is the XML file I have: Colonel Hello World Link to comment
Blueman Posted April 10, 2012 Author Share Posted April 10, 2012 Thanks I am not looking to do much I am just scripting for fun and the problem is it wouldn't save to the xml file but I will see if yours works. Also the script was just a test script thanks. Note: I was pretty tired when I wrote this so the debug string thing was probably due to that. :3 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