To help streamline things a bit around here (for the little work we actually do 😅), I’m going to be archiving the repos listed below. This doesn’t mean they’re broken or unusable, it just means we won’t be pushing any further updates to them for now.
Our main focus moving forward will be ps-mdt v3 and its dependencies.
The purpose of this script is to create and handle polyzones more efficiently for zone enter/leave events. Every zone is added to a overarching combozone which greatly improves perfomance looping over the normal distance checking via coords/distance of a point.
Each Polyzone needs to have a UNIQUE NAME otherwise it will get triggered each time there is a zone.
RegisterNetEvent("ps-zones:enter", function(ZoneName, ZoneData)
-- Code here
end)
RegisterNetEvent("ps-zones:leave", function(ZoneName, ZoneData)
-- Code here
end)
RegisterServerEvent("ps-zones:enter", function(ZoneName, ZoneData)
-- Code here
end)
RegisterServerEvent("ps-zones:leave", function(ZoneName, ZoneData)
-- Code here
end)
exports["ps-zones"]:CreatePolyZone(name, points, data)
exports["ps-zones"]:CreateBoxZone(name, point, length, width, data)
exports["ps-zones"]:CreateCircleZone(name, point, radius, data)
exports["ps-zones"]:CreateEntityZone(name, entity, data)
exports["ps-zones"]:DestroyZone(name)
-- Create Polyzone
exports["ps-zones"]:CreatePolyZone("poly-test", {
vector2(-7.88, -1058.93),
vector2(0.03, -1058.67),
vector2(-3.75, -1054.05),
}, {
debugPoly = true,
minZ = 38.16 - 1,
maxZ = 38.16 + 1,
})
-- Create Box Zone
RegisterCommand("box", function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
exports["ps-zones"]:CreateBoxZone("box-test", coords, 2.0, 2.0, {
debugPoly = true,
heading = 0.0,
minZ = coords.z - 1,
maxZ = coords.z + 1,
})
end)
-- Create Circle Zone
RegisterCommand("circle", function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
exports["ps-zones"]:CreateCircleZone("circle-test", coords, 5.0, {
debugPoly = true,
minZ = coords.z - 1,
maxZ = coords.z + 1,
})
end)
-- Create Entity Zone
RegisterCommand("entity", function()
local ped = PlayerPedId()
exports["ps-zones"]:CreateEntityZone("entity-test", ped, {
debugPoly = true,
useZ = false,
})
end)
