DirkScripts Documentation
  • 👋Welcome
  • The Basics
    • ⬇️Installing Resources
  • Resources
    • 📚Dirk Lib
      • Getting Started
      • Cache
      • Modules
        • Await
        • Blip
        • Callback
        • Camera
        • File
        • Interact
        • Objects
        • Player
          • Client
          • Server
        • Groups
          • Client
          • Server
        • Print
        • Request
        • Table
        • Target
        • Zones
        • UI
          • Context
          • Untitled
    • 🔧Project Cars
      • Installation
      • Tools
      • Parts
      • Commands
    • 🤼Multicharacter
      • Installation
      • Configuration
      • Exports
      • F.A.Q
      • Commands
    • 💊Drug Labs v2
      • Installation
      • Tebex Integration
      • Creating Labs
  • 🛒Store
  • 🗣️Discord
  • 🖥️GitHub
Powered by GitBook
On this page
  • lib.zones.register
  • Zone Examples
  • lib.zones.get
  • lib.zones.delete
  • lib.zones.isInsideZone
  • Data Structure
Export as PDF
  1. Resources
  2. Dirk Lib
  3. Modules

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

PreviousTargetNextUI

Last updated 10 months ago

Zone options, refer to

Game Zones:

📚
https://docs.fivem.net/natives/?_0xCD90657D4C30E1CA
Data Structure