DirkScripts Logo

Login With FiveM

Login

📚 Dirk Lib
â€ē
Modules
â€ē

zones

Zones

â„šī¸ Client & Server Module - Full zone system on client, utility functions available on server

lib.zones.register

Create a new zone

lua
lib.zones.register(id, data)
Parameter TypeRequiredDescription
nameStringtrueUnique zone reference
dataObjecttrueZone options, refer to Data Structure

Zone Examples

{% tabs %} {% tab title="cirlce" %}

lua
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,
})

{% endtab %}

{% tab title="circle2D" %}

lua
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,
})

{% endtab %}

{% tab title="poly" %}

lua
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,
})

{% endtab %}

{% tab title="box" %}

lua
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,
})

{% endtab %}

{% tab title="game_zone" %}

lua
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,
})

{% endtab %} {% endtabs %}

lib.zones.get

Get zone information

lua
local zone = lib.zones.get(name)
Parameter TypeRequiredDescription
nameStringtrueUnique zone reference

lib.zones.delete

Remove a created zone

lua
lib.zones.delete(name)
ParameterTypeRequiredDescription
namestringyesUnique zone reference

lib.zones.destroy

Alias for lib.zones.delete

lua
lib.zones.destroy(name)

lib.zones.getCenter

Get the center point of a polygon

lua
local center = lib.zones.getCenter(points)
ParameterTypeRequiredDescription
pointsvector3[]yesPolygon points

â„šī¸ getCenter and isPointInside are also available server-side.

lib.zones.isPointInside

Check if a position is inside a polygon

lua
local inside = lib.zones.isPointInside(points, pos, height)
ParameterTypeRequiredDescription
pointsvector3[]yesPolygon boundary points
posvector3yesPosition to test
heightnumbernoHeight of the polygon

lib.zones.isInsideZone

Check whether a position lies inside a zone(s)

lua
local isInside, zoneName = lib.zones.isInsideZone(name, pos)
Parameter TypeRequiredDescription
nameString, ObjecttrueUnique zone reference(s)
posVector3truePosition to be checked

Data Structure

This is the data structure of a blip and the valid options

lua
{
    -- 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:

{% tabs %} {% tab title="circle" %}

{
    pos = vector3(0, 0, 0),   -- Position of the zone
    radius = 5.0,             -- Size of the zone radially from the point
}

{% endtab %}

{% tab title="circle2D" %}

lua
{
    pos = vector2(0, 0),      -- Position of the zone
    radius = 5.0,             -- Size of the zone radially from the point
}

{% endtab %}

{% tab title="poly" %}

{
    points = {                -- Boundy marks for the polyzone
        vector2(0, 0),
        vector2(2, 1),
        vector2(3, 3),
    }
}

{% endtab %}

{% tab title="box" %}

lua
{
    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
}

{% endtab %}

{% tab title="game_zone" %}

lua
{
    gameZone = "ALTA"
}

Game Zones: https://docs.fivem.net/natives/?_0xCD90657D4C30E1CA ↗ {% endtab %} {% endtabs %}

Copyright Š 2026 DirkScripts.

Not affiliated with or endorsed by Rockstar North, Take-Two Interactive, or any other rights holders. FiveM is a copyright and registered trademark of Take-Two Interactive Software, Inc.
Our checkout system is provided by Tebex Limited, who manage payment processing, product delivery, and billing support. Prices shown in currencies other than GBP are approximate conversions updated daily. All purchases are processed in GBP, so the final amount charged may vary depending on your bank or payment provider’s exchange rate.