Jump to content

just a question


mjau

Recommended Posts

Posted

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

Posted

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) 
  

Posted (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 by Guest
Posted

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.

Posted

Xthepromise i know how to create the file i just wanted a way to create that line for my houseSystem... anyway tnx

Posted

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

Posted

another question

how can i loop trough all the house childrens in the file and create a housepickup at the positions ?

Posted

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....

Posted
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 

Posted

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 

Posted
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.

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...