Jump to content

change script format


5150

Recommended Posts

how can i make this so i can add a few colshapes instead of the width, depth, height shit?

-- storage for the zones 
-- Format is: {x = 0, y = 0, z = 0, width = 0, depth = 0, height = 0}, 
local vZones = { 
    {x = 77.89, y = 1011.84, z = 12, width = 63.97, depth = 101.42, height = 32.88}, -- random example location located in Bone County 
} 
  
-- initialize all zones on resource start 
local z = {} 
function initvZones() 
    if vZones and #vZones ~= 0 then 
        for _,v in ipairs (vZones) do 
            if v then 
                if v.x and v.y and v.z and v.width and v.depth and v.height then 
                    local c = createColCuboid (v.x, v.y, v.z, v.width, v.depth, v.height) 
                    if c then 
                        z[c] = true 
                        for _,v in ipairs (getElementsByType("vehicle")) do 
                            if isElementWithinColShape (v, c) then 
                                destroyElement(v) 
                            end 
                        end 
                        addEventHandler ("onElementDestroy", c, 
                            function() 
                                if z[source] then 
                                    z[source] = nil 
                                end 
                            end 
                        ) 
                        addEventHandler ("onColShapeHit", c, 
                            function (h, d) 
                                if h and d and isElement(h) and getElementType (h) == "vehicle" then 
                                    destroyElement (h) 
                                end 
                            end 
                        ) 
                    end 
                end 
            end 
        end 
    end 
end 
addEventHandler ("onResourceStart", resourceRoot, initvZones) 

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