function initGreenzones()
if greenzones and #greenzones ~= 0 then
for _,v in ipairs (greenzones) 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)
local rarea = createRadarArea (v.x, v.y, v.width, v.depth, 0, 255, 0, 150)
setElementParent (rarea, c)
if c then
z[c] = true
for _,p in ipairs (getElementsWithinColShape(c, "player")) do
setElementData (p, "greenzone", true)
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) == "player" then
setElementData (h, "greenzone", true)
outputChatBox ("* Greenzone * You have entered the greenzone", h, 0, 220, 0)
toggleControl (h, "fire", false)
toggleControl (h, "next_weapon", false)
toggleControl (h, "previous_weapon", false)
toggleControl (h, "aim_weapon", false)
toggleControl (h, "vehicle_fire", false)
end
end
)
addEventHandler ("onColShapeLeave", c,
function (h, d)
if h and d and isElement(h) and getElementType (h) == "player" then
removeElementData (h, "greenzone")
outputChatBox ("* Greenzone * You have left the greenzone", h, 220, 220, 0)
toggleControl (h, "fire", true)
toggleControl (h, "next_weapon", true)
toggleControl (h, "previous_weapon", true)
toggleControl (h, "sprint", true)
toggleControl (h, "aim_weapon", true)
toggleControl (h, "vehicle_fire", true)
end
end
)
end
end
end
end
end
end