PauloCascus Posted July 7, 2014 Share Posted July 7, 2014 Hey guys how i can to use xml file for spawn player I want to create spawn panel with xml but i don't know how synchronize panel with xml file So i thought about it like: local xml = xmlLoadFile ( xmlName ) then will be created GUI panel and when player will press button, function like: local xmlSpawn = xmlNodeGetAttribute ( xml, name ) if xmlSpawn == "SpawnName" then local PosX = xmlNodeGetAttribute ( xml, spawnX ) local PosY = xmlNodeGetAttribute ( xml, spawnY ) local PosZ = xmlNodeGetAttribute ( xml, spawnZ ) local Rot = xmlNodeGetAttribute ( xml, rot ) local Skin = xmlNodeGetAttribute ( xml, skin ) spawnPlayer ( thePlayer, tonumber(PosX), tonumber(PosY), tonumber(PosZ), tonumber(Rot), skin ) but i think i will need to create so many xml's for every spawn... so sadly Somebody can help me and show me a way of using xml, which will be better <spawn name="SpawnName" spawnX="positionX" spawnY="positionY" spawnZ="positionZ" rot="rotation" skin="50"/> Link to comment
Arnold-1 Posted July 7, 2014 Share Posted July 7, 2014 ok, i will tell you how to fix it, just so you can learn XML, by try using setAccountData xml = xmlLoadFile("file.xml") children = xmlNodeGetChildren(xml) for i,v in ipairs(children) do name = xmlNodeGetAttribute(v,"name") if name == getPlayerName(thePlayer) then local x = xmlNodeGetAttribute(v,"spawnX") local y = xmlNodeGetAttribute(v,"spawnY") local z = xmlNodeGetAttribute(v,"spawnZ") spawnPlayer(thePlayer,x,y,z) end end But i highly recommend using Account data. Link to comment
PauloCascus Posted July 8, 2014 Author Share Posted July 8, 2014 ok, i will tell you how to fix it, just so you can learn XML, by try using setAccountData xml = xmlLoadFile("file.xml") children = xmlNodeGetChildren(xml) for i,v in ipairs(children) do name = xmlNodeGetAttribute(v,"name") if name == getPlayerName(thePlayer) then local x = xmlNodeGetAttribute(v,"spawnX") local y = xmlNodeGetAttribute(v,"spawnY") local z = xmlNodeGetAttribute(v,"spawnZ") spawnPlayer(thePlayer,x,y,z) end end But i highly recommend using Account data. i said about Spawn Name like Drug Dealer i think it must to be as : --- at the beggining of script xml = xmlLoadFile("file.xml") ---------------------------------------------------------- Then player select spawn options and press the button "Spawn" children = xmlFindChild( xml, spawn ) for i,v in ipairs(children) do spawnname = xmlNodeGetAttribute(v,"name") local x = xmlNodeGetAttribute(v,"spawnX") local y = xmlNodeGetAttribute(v,"spawnY") local z = xmlNodeGetAttribute(v,"spawnZ") local rot = xmlNodeGetAttribute (v, "rot" ) local skin = xmlNodeGetAttribute (v, "skin" ) spawnPlayer( source ,x,y,z, rot, skin, 0, 0, name ) end end Link to comment
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