Jump to content

About XML


xeon17

Recommended Posts

Posted

Hi guys i want to know how to save color of a radararea in a XML file , for me XML look easiest way to do it because i don't know anything about SQL or Mysql

Can anyone give me example to save color of a radar area in xml file , and explain me how everything work.

Ty :D

Posted
local file = xmlCreateFile("file.xml", "data") 
local child = xmlCreateChild(file, "radararea") 
xmlNodeSetAttribute(child, "colorR", yourcolorR) 
xmlNodeSetAttribute(child, "colorG", yourcolorG) 
xmlNodeSetAttribute(child, "colorB", yourcolorB) 
xmlSaveFile(file) 
xmlUnloadFile(file) 

Fast-typed, can be wrong, but doubt it.

Here are all XML functions:

https://wiki.multitheftauto.com/wiki/Xml

Posted

It's still hard for me but , i'll check every function .

Should i put my xml code in the Lua file , where i created the radar area or there is any way i can save all radar areas on server?

Posted
local gAreas = getElementsByType("radararea") 
for placeNumber, areaData in ipairs(gAreas) do 
    --Get stuff and place them into XML 
end 
--Later, when you want to receive them: 
local xmlLoadFile("file.xml") 
local child = xmlFindChild(file,  
local gChildren = xmlNodeGetChildren(child) 
for placeNumber, childrenData in ipairs(gChildren) do 
    --Get attributes (Like position, colors, etc.) and use them 
end 

Just make a random XML file, and try creating some childs and finding them. Also with attributes. Explanations are on wiki.

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