Jump to content

[HELP] XML / Moving gate!


squar

Recommended Posts

After this line:

local colX, colY, colZ, colSize, model, posX, posY, posZ, rotX, rotY, rotZ, team, moveSpeed, moveX, moveY, moveZ = unpack(v) 

Put:

local colX, colY, colZ, colSize, model, posX, posY, posZ, rotX, rotY, rotZ, team, moveSpeed, moveX, moveY, moveZ = unpack(v) 
outputChatBox ( tostring ( posX ) ..", ".. tostring ( posY ) ..", ".. tostring ( posZ ) ) 

Link to comment
local gates = {} 
  
function gatesLoad() 
    setTimer(function() 
        local xmlNode = xmlLoadFile("gates.xml") 
        if not xmlNode then outputDebugString("Invalid xml file") return end 
        local children = xmlNodeGetChildren(xmlNode) 
        for k, node in ipairs(children) do 
            if xmlNodeGetName(node) == "gate" then 
                local colX, colY, colZ, colSize = tonumber(xmlNodeGetAttribute(node, "colX")), tonumber(xmlNodeGetAttribute(node, "colY")), tonumber(xmlNodeGetAttribute(node, "colZ")), tonumber(xmlNodeGetAttribute(node, "colSize")) 
                local model, posX, posY, posZ = tonumber(xmlNodeGetAttribute(node, "model")), tonumber(xmlNodeGetAttribute(node, "posX")), tonumber(xmlNodeGetAttribute(node, "posY")), tonumber(xmlNodeGetAttribute(node, "posZ")) 
                local rotX, rotY, rotZ = tonumber(xmlNodeGetAttribute(node, "rotX")),tonumber(xmlNodeGetAttribute(node, "rotY")),tonumber(xmlNodeGetAttribute(node, "rotZ")) 
                local team, moveSpeed, moveX, moveY, moveZ = tonumber(xmlNodeGetAttribute(node, "teamLock")), tonumber(xmlNodeGetAttribute(node, "moveSpeed")), tonumber(xmlNodeGetAttribute(node, "moveX")), tonumber(xmlNodeGetAttribute(node, "moveY")), tonumber(xmlNodeGetAttribute(node, "moveZ"))                  
                
                table.insert(gates, {colX, colY, colZ, colSize, model, posX, posY, posZ, rotX, rotY, rotZ, team, moveSpeed, moveX, moveY, moveZ}) 
            end 
        end 
        outputDebugString("Gates successfully loaded") 
        for i,v in ipairs(gates) do 
            local colX, colY, colZ, colSize, model, posX, posY, posZ, rotX, rotY, rotZ, team, moveSpeed, moveX, moveY, moveZ = unpack(v) 
            local col = createColSphere(colX,colY,colZ,colSize) 
            local gate = createObject(model,posX,posY,posZ,rotX,rotY,rotZ) 
            --setElementVisibleTo(col,getRootElement (),false) 
            addEventHandler("onColShapeHit", col, 
                function(hitElement) 
                    local theTeam = getPlayerTeam(hitElement) 
                    if not theTeam then return end 
                    if (getTeamName(theTeam) == "Staff") then 
                        moveObject(gate,moveSpeed,moveX,moveY,moveZ, 0, 0, 0) 
                    end 
                end 
            ) 
  
            addEventHandler("onColShapeLeave", col, 
                function(leaveElement) 
                    local theTeam2 = getPlayerTeam(leaveElement) 
                    if not theTeam2 then return end 
                    if (getTeamName(theTeam2) == "Staff") then 
                        moveObject(gate,moveSpeed,posX,posY,posZ, 0, 0, 0) 
                    end 
                end 
            ) 
        end 
    end 
    , 5000, 1) 
end 
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), gatesLoad) 

Link to comment

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