Taalasmaa Posted March 20, 2010 Posted March 20, 2010 Yo, I'm very and I mean very newbie in XML. I can script lua very well, but I'm not ever practised XML's. I'm just testing this: function test2(thePlayer) mission = xmlLoadFile("test.xml") local newFinish = xmlCreateChild(mission, "newMission" ); x,y,z = getElementPosition(thePlayer) xmlNodeSetAttribute( newFinish, "posX", x ); xmlNodeSetAttribute( newFinish, "posY", y ); xmlNodeSetAttribute( newFinish, "posZ", z ); end addCommandHandler("test", test2) Why this isn't working. In debugscript it's giving Bad Arguement @ xmlCreateChild, Bad Arguement @ xmlNodeSetAttribute Thanks. http://www.sincitygaming.net - The next generation of gaming! SinCity Gaming | UltiRace 24/7 - 188.165.199.162:22003 SinCity Gaming | Roleplay Gaming - Beta soon! SinCity Gaming | Zombie Mode + - 188.165.199.162:22005 Instead of using ip: 188.165.199.162 you can use: sincitygaming.net
Gamesnert Posted March 20, 2010 Posted March 20, 2010 xmlNodeSetAttribute fails because xmlCreateChild fails. xmlCreateChild seems ok, though. So I'm expecting that for some reason, test.xml couldn't be loaded. Perhaps you haven't this file yet? Or perhaps you've just got the wrong name / directory? Projects: Slothbot | Maximap
Taalasmaa Posted March 20, 2010 Author Posted March 20, 2010 xmlNodeSetAttribute fails because xmlCreateChild fails.xmlCreateChild seems ok, though. So I'm expecting that for some reason, test.xml couldn't be loaded. Perhaps you haven't this file yet? Or perhaps you've just got the wrong name / directory? test.xml is in the same directory than the script itself. Name is test.xml And I got the file, so far. Also I checked that test.xml doesn't have any big letters like "Test.xml"- http://www.sincitygaming.net - The next generation of gaming! SinCity Gaming | UltiRace 24/7 - 188.165.199.162:22003 SinCity Gaming | Roleplay Gaming - Beta soon! SinCity Gaming | Zombie Mode + - 188.165.199.162:22005 Instead of using ip: 188.165.199.162 you can use: sincitygaming.net
Gamesnert Posted March 20, 2010 Posted March 20, 2010 test.xml is in the same directory than the script itself. The only thing I can think of then is an error in the XML file. Projects: Slothbot | Maximap
karlis Posted March 20, 2010 Posted March 20, 2010 might xml file dont get rootnode? and u need specify parentnode for xmlcreatechild, not xml file itself i think try if not mission then xmlCreateFile("test.xml","rootnode") end [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
Taalasmaa Posted March 20, 2010 Author Posted March 20, 2010 might xml file dont get rootnode?and u need specify parentnode for xmlcreatechild, not xml file itself i think try if not mission then xmlCreateFile("test.xml","rootnode") end Still not working . Any other things? http://www.sincitygaming.net - The next generation of gaming! SinCity Gaming | UltiRace 24/7 - 188.165.199.162:22003 SinCity Gaming | Roleplay Gaming - Beta soon! SinCity Gaming | Zombie Mode + - 188.165.199.162:22005 Instead of using ip: 188.165.199.162 you can use: sincitygaming.net
Taalasmaa Posted March 20, 2010 Author Posted March 20, 2010 Really weird.. I added resourceRoot = getResourceRootElement( getThisResource( ) ) addEventHandler("onResourceStart", resourceRoot, function( ) local mission = xmlCreateFile ( "test.xml", "root" ); outputChatBox("test.xml created succesfully") end ) and removed old test.xml for test, but it's not EVEN creating new test.xml http://www.sincitygaming.net - The next generation of gaming! SinCity Gaming | UltiRace 24/7 - 188.165.199.162:22003 SinCity Gaming | Roleplay Gaming - Beta soon! SinCity Gaming | Zombie Mode + - 188.165.199.162:22005 Instead of using ip: 188.165.199.162 you can use: sincitygaming.net
Gamesnert Posted March 20, 2010 Posted March 20, 2010 This function creates a new XML document, which can later be saved to a file by using xmlSaveFile. This function will overwrite the file specified if it already exists. Explanations, big or small, the Wiki has it all. Projects: Slothbot | Maximap
Taalasmaa Posted March 20, 2010 Author Posted March 20, 2010 This function creates a new XML document, which can later be saved to a file by using xmlSaveFile. This function will overwrite the file specified if it already exists. function test2() if not xmlLoadFile( "test.xml" ) then local mission = xmlCreateFile ( "test.xml", "root" ); local new1 = xmlCreateChild( mission, "newFinish" ); xmlSaveFile( mission ); end end addCommandHandler("test", test2) Tried this too. It only Gives <root/> To test.xml file. It's not creating "newFinish". http://www.sincitygaming.net - The next generation of gaming! SinCity Gaming | UltiRace 24/7 - 188.165.199.162:22003 SinCity Gaming | Roleplay Gaming - Beta soon! SinCity Gaming | Zombie Mode + - 188.165.199.162:22005 Instead of using ip: 188.165.199.162 you can use: sincitygaming.net
Gamesnert Posted March 20, 2010 Posted March 20, 2010 Debug it, check what xmlCreateChild returns. Projects: Slothbot | Maximap
Taalasmaa Posted March 20, 2010 Author Posted March 20, 2010 function test2() if not xmlLoadFile( "test.xml" ) then local mission = xmlCreateFile ( "test.xml", "root" ); local new1 = xmlCreateChild( mission, "Car" ); vehicle = getPedOccupiedVehicle(source) xmlNodeSetAttribute( new1, "Veh", vehicle ); xmlSaveFile( mission ); end end addCommandHandler("test", test2) Okay, tried this1 too, now. It's not giving ANY errors in debugscript.. Just shows in test.xml. And, I was in a car, lol. http://www.sincitygaming.net - The next generation of gaming! SinCity Gaming | UltiRace 24/7 - 188.165.199.162:22003 SinCity Gaming | Roleplay Gaming - Beta soon! SinCity Gaming | Zombie Mode + - 188.165.199.162:22005 Instead of using ip: 188.165.199.162 you can use: sincitygaming.net
Taalasmaa Posted March 20, 2010 Author Posted March 20, 2010 I got it working. Thanks anyway for everyone who helped me :b! http://www.sincitygaming.net - The next generation of gaming! SinCity Gaming | UltiRace 24/7 - 188.165.199.162:22003 SinCity Gaming | Roleplay Gaming - Beta soon! SinCity Gaming | Zombie Mode + - 188.165.199.162:22005 Instead of using ip: 188.165.199.162 you can use: sincitygaming.net
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