mjau Posted January 23, 2012 Posted January 23, 2012 Hi i have almost never worked with xml before just some descriptions for a spawnmenu but today i tought i should learn more about it so i have a housecreator GUI wich functions in what order i need to make a xml line exactly like this? "" markerPosY="" markerPosZ="" owner="" />
BriGhtx3 Posted January 23, 2012 Posted January 23, 2012 TO CREATE A FILE : xmlFile= xmlCreateFile ( "YOURXML.xml", "root" ) -- Create the xml file xmlHouses = xmlCreateChild ( xmlFile, "house") -- CREATE THE TAG xmlNodeSetAttribute(xmlHouses,"markerPosX", "VALUE1") -- CREATE THE MARKERPOSX PART xmlNodeSetAttribute(xmlHouses,"markerPosY", "VALUE2") -- SAME WITH Y xmlNodeSetAttribute(xmlHouses,"markerPosZ", "VALUE3") -- SAME WITH Z xmlNodeSetAttribute(xmlHouses,"owner", "VALUE4") -- SAME WITH OWNER TO GET THE X,Y,Z, OWNER : posX = xmlNodeGetAttribute(xmlFile, "markerPosX") posY = xmlNodeGetAttribute(xmlFile, "markerPosY") posZ = xmlNodeGetAttribute(xmlFile, "markerPosZ") owner = xmlNodeGetAttribute(xmlFile, "owner") outputChatBox("X : "..posX.." Y : "..posY.." Z : "..posZ.." Owner : "..owner) Currently working on gamemodes : Reallife Script 70% Breakout Script 10%
Kenix Posted January 23, 2012 Posted January 23, 2012 (edited) Better Server do local house = getElementsByType( "house" ) if #house > 0 then for _,v in pairs( house ) do mark = createMarker( getElementData( v,"markerPosX" ), getElementData( v,"markerPosY" ), getElementData( v,"markerPosZ" ) ) setElementData( mark,"owner",getElementData( v,"owner" ) ) end end end <map> <house markerPosX="0" markerPosY="0" markerPosZ="10" owner="some" /> </map> Edited January 23, 2012 by Guest http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
BriGhtx3 Posted January 23, 2012 Posted January 23, 2012 Kenix he wants to have a xml file Currently working on gamemodes : Reallife Script 70% Breakout Script 10%
Kenix Posted January 23, 2012 Posted January 23, 2012 Yes i know. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
BriGhtx3 Posted January 23, 2012 Posted January 23, 2012 And why do you use getElementData without setting it? Currently working on gamemodes : Reallife Script 70% Breakout Script 10%
Kenix Posted January 23, 2012 Posted January 23, 2012 Because house is element and you can get data. But it only in map file. So add to meta.xml <map src="some.map" /> <map> <house markerPosX="0" markerPosY="0" markerPosZ="10" owner="some" /> </map> I test it now. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
mjau Posted January 23, 2012 Author Posted January 23, 2012 Xthepromise i know how to create the file i just wanted a way to create that line for my houseSystem... anyway tnx
BriGhtx3 Posted January 23, 2012 Posted January 23, 2012 Kenix Ah, you mean you create it via a map file and get the elementdata by the type. Currently working on gamemodes : Reallife Script 70% Breakout Script 10%
Kenix Posted January 23, 2012 Posted January 23, 2012 if need create housecreator i think better use mysql/sql because you can easy change it. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
mjau Posted January 23, 2012 Author Posted January 23, 2012 well mySQL is too hard for me read JR10 tut and things but i dont understand it so i wanted to do it with XML since i understand it better
mjau Posted January 23, 2012 Author Posted January 23, 2012 another question how can i loop trough all the house childrens in the file and create a housepickup at the positions ?
BriGhtx3 Posted January 23, 2012 Posted January 23, 2012 for i,v in ipairs(xmlNodeGetChildren(xmlFile)) xmlNodeGetAttribute(xmlFile, v) end Currently working on gamemodes : Reallife Script 70% Breakout Script 10%
mjau Posted January 23, 2012 Author Posted January 23, 2012 What ? how do i create the pickup at the cordinates ? this doesent return x y and z pos ? im making a function to create a housepickup at every house saved in my xml file....
BriGhtx3 Posted January 23, 2012 Posted January 23, 2012 xmlFile = xmlLoadFile("XML.xml") for i,v in ipairs(xmlNodeGetChildren(xmlFile)) posX = xmlNodeGetAttribute(xmlFile, "markerPosX") posY = xmlNodeGetAttribute(xmlFile, "markerPosY") posZ = xmlNodeGetAttribute(xmlFile, "markerPosZ") owner = xmlNodeGetAttribute(xmlFile, "owner") outputChatBox("X : "..posX.." Y : "..posY.." Z : "..posZ.." Owner : "..owner) end Currently working on gamemodes : Reallife Script 70% Breakout Script 10%
mjau Posted January 23, 2012 Author Posted January 23, 2012 why this dont work says bad argument at create pickp line function reloadHouses() file = xmlLoadFile("XML/houseData.xml") for i,v in ipairs(xmlNodeGetChildren(file)) do posX = xmlNodeGetAttribute(file, "markerPosX") posY = xmlNodeGetAttribute(file, "markerPosY") posZ = xmlNodeGetAttribute(file, "markerPosZ") owner = xmlNodeGetAttribute(file, "owner") houseIcon = createPickup(posX, posY, posZ, 3, 1273, 1000) end end
BriGhtx3 Posted January 23, 2012 Posted January 23, 2012 function reloadHouses() file = xmlLoadFile("XML/houseData.xml") for i,v in ipairs(xmlNodeGetChildren(file)) do posX = xmlNodeGetAttribute(v, "markerPosX") posY = xmlNodeGetAttribute(v, "markerPosY") posZ = xmlNodeGetAttribute(v, "markerPosZ") owner = xmlNodeGetAttribute(v, "owner") houseIcon = createPickup(posX, posY, posZ, 3, 1273, 1000) end end Sorry my error You have to replace the file in the for tags with v. Currently working on gamemodes : Reallife Script 70% Breakout Script 10%
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