Zones
Used to create and manage polyzones
lib.zones.register
Create a new zone
lib.zones.register(id, data)Parameter
Type
Required
Description
name
String
Unique zone reference
Zone Examples
lib.zone.register("exampleZone", {
type = "circle",
pos = vector3(0, 0, 0),
radius = 5.0,
onEnter = function(data)
lib.print("debug", "Entered Zone")
end,
onExit = function(data)
lib.print("debug", "Exited Zone")
end,
})lib.zone.register("exampleZone", {
type = "circle2D",
pos = vector2(0, 0),
radius = 5.0,
onEnter = function(data)
lib.print("debug", "Entered Zone")
end,
onExit = function(data)
lib.print("debug", "Exited Zone")
end,
})local polyPoints = {
vector2(0, 0),
vector2(10, 10),
vector2(20, 20),
vector2(0, 30),
vector2(-10, 15),
}
lib.zone.register("exampleZone", {
type = "poly",
pos = polyPoints,
onEnter = function(data)
lib.print("debug", "Entered Zone")
end,
onExit = function(data)
lib.print("debug", "Exited Zone")
end,
})lib.zone.register("exampleZone", {
type = "box",
pos = vector4(0, 0, 0, 0),
size = vector3(0, 0, 0),
onEnter = function(data)
lib.print("debug", "Entered Zone")
end,
onExit = function(data)
lib.print("debug", "Exited Zone")
end,
})lib.zone.register("exampleZone", {
type = "game_zone",
gameZone = "ALTA"
onEnter = function(data)
lib.print("debug", "Entered Zone")
end,
onExit = function(data)
lib.print("debug", "Exited Zone")
end,
})lib.zones.get
Get zone information
local zone = lib.zones.get(name)Parameter
Type
Required
Description
name
String
Unique zone reference
lib.zones.delete
Remove a created zone
lib.zones.delete(name)Parameter
Type
Required
Description
name
String
Unique zone reference
lib.zones.isInsideZone
Check whether a position lies inside a zone(s)
local isInside, zoneName = lib.zones.isInsideZone(name, pos)Parameter
Type
Required
Description
name
StringObject
Unique zone reference(s)
pos
Vector3
Position to be checked
Data Structure
This is the data structure of a blip and the valid options
{
-- Required
type = "circle", -- Type of zone: circle, circle2D, poly, box, game_zone
-- Not Required
onEnter = function(data)
-- Callback for entering the zone
end,
onExit = function(data)
-- Callback for exiting the zone
end,
}Some zones have different requirements, see below:
{
pos = vector3(0, 0, 0), -- Position of the zone
radius = 5.0, -- Size of the zone radially from the point
}{
pos = vector2(0, 0), -- Position of the zone
radius = 5.0, -- Size of the zone radially from the point
}{
points = { -- Boundy marks for the polyzone
vector2(0, 0),
vector2(2, 1),
vector2(3, 3),
}
}{
pos = vector4(0,0,0,0), -- Position of the zone, x, y, z, heading
size = vector3(0,0,0) -- Size of the zone from the center point
}{
gameZone = "ALTA"
}Game Zones: https://docs.fivem.net/natives/?_0xCD90657D4C30E1CA
Last updated