xXMADEXx Posted March 28, 2013 Share Posted March 28, 2013 Im making a script to make garages, but for some reason all the garages are finding the x,y,z of the last created garage. Im not sure how to fix this... server.lua ---------------------------------------------------- -- Author: xXMADEXx -- File: server.lua -- copywrite 2013 (C) Revolution of Gaming ---------------------------------------------------- function createMiliSpawner(player) local x,y,z = getElementPosition(player) local city = getZoneName(x,y,z,true) local zone = getZoneName(x,y,z) if isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( player ) ), aclGetGroup ( "lvl 6" ) ) then -- loading file = xmlLoadFile("garages.xml", "garages") child = xmlCreateChild(file,"garage") -- City/zone --- xmlNodeSetAttribute(child,"city",city) xmlNodeSetAttribute(child,"zone",zone) --- Marker --- xmlNodeSetAttribute(child,"markerX",x) xmlNodeSetAttribute(child,"markerY",y) xmlNodeSetAttribute(child,"markerZ",z - 1) --- Garage Door --- xmlNodeSetAttribute(child,"garagedoorX",x+3.2) xmlNodeSetAttribute(child,"garagedoorY",y+0.4) xmlNodeSetAttribute(child,"garagedoorZ",z+1) --- Opening Door --- xmlNodeSetAttribute(child,"toX",x+3.2) xmlNodeSetAttribute(child,"toY",y+0.4) xmlNodeSetAttribute(child,"toZ",z+4) --- Save & Exit --- xmlSaveFile(file) xmlUnloadFile(file) marker = createMarker(x,y,z-1,"cylinder",2,255,255,0,100) end end addCommandHandler("ga",createMiliSpawner) marker = {} garage = {} door = {} function loadMyMiliMainSPawners () local file = xmlLoadFile ("garages.xml", "garages") for k, v in ipairs ( xmlNodeGetChildren ( file ) ) do -- Marker -- local markerX = xmlNodeGetAttribute(v,"markerX") local markerY = xmlNodeGetAttribute(v,"markerY") local markerZ = xmlNodeGetAttribute(v,"markerZ") marker[k] = createMarker(markerX,markerY,markerZ,"cylinder",2, 255, 255, 0, 100) -- Garage -- garage[k] = createObject(17950,markerX+3.2,markerY+4.7,markerZ+2,0,0,180) -- Garage Door -- doorX = xmlNodeGetAttribute(v,"garagedoorX") doorY = xmlNodeGetAttribute(v,"garagedoorY") doorZ = xmlNodeGetAttribute(v,"garagedoorZ") toX = xmlNodeGetAttribute(v,"toX") toY = xmlNodeGetAttribute(v,"toY") toZ = xmlNodeGetAttribute(v,"toZ") door[k] = createObject(17951,tonumber(doorX),tonumber(doorY),tonumber(doorZ),0,0,90) addEventHandler("onMarkerHit",marker[k], function () if (getElementData(door[k],"status") ~= "open") then setElementData(door[k],"status","open",true) moveObject(door[k],2000,toX,toY,toZ) setTimer( function () moveObject(door[k],2000,doorX,doorY,doorZ) setElementData(door[k],"status","closed",true) end, 20000, 1 ) else moveObject(door[k],2000,doorX,doorY,doorZ) setElementData(door[k],"status","closed",true) end end ) end end addEventHandler("onResourceStart",root, loadMyMiliMainSPawners) Example of the Errors: 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