Zones

Used to create and manage polyzones

Client Module - This can only be used on the client

lib.zones.register

Create a new zone

lib.zones.register(id, data)
Parameter
Type
Required
Description

name

String

Unique zone reference

data

Object

Zone options, refer to Data Structure

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

Last updated