Jump to content

just a question


mjau

Recommended Posts

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="" /> 

Link to comment

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) 
  

Link to comment

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 by Guest
Link to comment
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 

Link to comment

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 

Link to comment
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 :D

You have to replace the file in the for tags with v.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...