Alen141 Posted July 24, 2013 Posted July 24, 2013 Hey guys I need help ,again, more like tip.. How to learn creating xml files in wich I can edit and make things as : ---- Making some stuff client and server side and then make it easier to create( perhaps respawn points ) ----- " x, y, z " /> ---- or for jobs ---- "NAMEHERE" description = "" skin= "" pos = "" /> ---- Not exactly like that, but kind of like that
Vector Posted July 24, 2013 Posted July 24, 2013 xmlCreateFile xmlSaveFile xmlUnloadFile xmlCreateChild xmlNodeSetAttribute
Alen141 Posted July 24, 2013 Author Posted July 24, 2013 xmlCreateFile xmlSaveFile xmlUnloadFile xmlCreateChild xmlNodeSetAttribute can you suggest me any resource to use as an example to guide me?
Vector Posted July 25, 2013 Posted July 25, 2013 this is a silly example. suppose you want to save information of all the players that enters in your server. (name, tagcolor, ip...) -- this will create the xml file in which info will be holded. addEventHandler ("onResourceStart", getResourceRootElement (getThisResource ()), function () local fileInfo = xmlCreateFile ("playerInfo.xml", "info"); assert (fileInfo, "Fail to create xml file"); xmlSaveFile (fileInfo); xmlUnloadFile (fileInfo); end); -- this will save info about the player who connects to the server. addEventHandler ("onPlayerJoin", getRootElement (), function () -- get player info. local version = getPlayerVersion (source); local ip = getPlayerIP (source); local name = getPlayerName (source); local serial = getPlayerSerial (source); -- open the file local fileInfo = xmlOpenFile ("playerInfo.xml"); -- create a new node for this player. local node = xmlCreateChild (fileInfo, "player"); -- save info. xmlNodeSetAttribute (node, "name", name); xmlNodeSetAttribute (node, "ip", ip); xmlNodeSetAttribute (node, "version", version); xmlNodeSetAttribute (node, "serial", version); xmlSaveFile (fileInfo); -- this will save all the changes done in the file. xmlUnloadFile (fileInfo); -- close file handle. end); suppose a player called __Vector__ enters to the server. when this happens, a new node will be created in the file... name="__Vector__" version="1.3.0...." ip="..." serial="..." />
Alen141 Posted July 25, 2013 Author Posted July 25, 2013 this is a silly example. suppose you want to save information of all the players that enters in your server.(name, tagcolor, ip...) -- this will create the xml file in which info will be holded. addEventHandler ("onResourceStart", getResourceRootElement (getThisResource ()), function () local fileInfo = xmlCreateFile ("playerInfo.xml", "info"); assert (fileInfo, "Fail to create xml file"); xmlSaveFile (fileInfo); xmlUnloadFile (fileInfo); end); -- this will save info about the player who connects to the server. addEventHandler ("onPlayerJoin", getRootElement (), function () -- get player info. local version = getPlayerVersion (source); local ip = getPlayerIP (source); local name = getPlayerName (source); local serial = getPlayerSerial (source); -- open the file local fileInfo = xmlOpenFile ("playerInfo.xml"); -- create a new node for this player. local node = xmlCreateChild (fileInfo, "player"); -- save info. xmlNodeSetAttribute (node, "name", name); xmlNodeSetAttribute (node, "ip", ip); xmlNodeSetAttribute (node, "version", version); xmlNodeSetAttribute (node, "serial", version); xmlSaveFile (fileInfo); -- this will save all the changes done in the file. xmlUnloadFile (fileInfo); -- close file handle. end); suppose a player called __Vector__ enters to the server. when this happens, a new node will be created in the file... name="__Vector__" version="1.3.0...." ip="..." serial="..." /> ty, this was actually very helpful
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