> For the complete documentation index, see [llms.txt](https://docs.cuxial.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cuxial.com/scripts/core/cuxial-safezones/developers.md).

# Exports & events

Public API of Cuxial Safezones: exports to read the zones and open the panel from other resources.

Ask whether a player is inside a safe zone, read the zones or open the panel from your own resources.

## Client exports

### IsInSafeZone

Tells whether the local player is inside an active safe zone.

```lua
local inside = exports.cuxial_safezones:IsInSafeZone()
```

**Returns:** `boolean`. It is `true` inside the zone even when an exception lets the player skip its rules.

```lua
if exports.cuxial_safezones:IsInSafeZone() then
    return lib.notify({ description = 'Not inside a safe zone.', type = 'error' })
end
```

### GetCurrentSafeZone

Returns the zone the local player is in.

```lua
local zone = exports.cuxial_safezones:GetCurrentSafeZone()
```

**Returns:** `table | nil`. A [zone object](#zone-object), or `nil` outside any zone.

```lua
local zone = exports.cuxial_safezones:GetCurrentSafeZone()
if zone then print(zone.id, zone.label) end
```

### OpenZonesUI

Opens the zone panel for the local player.

```lua
exports.cuxial_safezones:OpenZonesUI()
```

{% hint style="warning" %}
This export does not check permissions. Check the permission yourself before calling it. Every change is still verified on the server against the `admin` ACE.
{% endhint %}

### CloseZonesUI

Closes the panel.

```lua
exports.cuxial_safezones:CloseZonesUI()
```

## Server exports

### GetSafeZones

Returns every zone, including the ones turned off.

```lua
local zones = exports.cuxial_safezones:GetSafeZones()
```

**Returns:** `table<number, table>`. [Zone objects](#zone-object) indexed by zone id.

```lua
for id, zone in pairs(exports.cuxial_safezones:GetSafeZones()) do
    print(id, zone.label, zone.active)
end
```

### GetSafeZone

Returns one zone.

```lua
local zone = exports.cuxial_safezones:GetSafeZone(id)
```

| Parameter | Type   | Description |
| --------- | ------ | ----------- |
| `id`      | number | Zone id.    |

**Returns:** `table | nil`.

```lua
local zone = exports.cuxial_safezones:GetSafeZone(3)
if zone and zone.active then print(zone.label) end
```

## Zone object

| Field                      | Type      | Description                                                                                       |
| -------------------------- | --------- | ------------------------------------------------------------------------------------------------- |
| `id`                       | number    | Zone id.                                                                                          |
| `label`                    | string    | Zone name.                                                                                        |
| `active`                   | boolean   | `false` when the zone is turned off.                                                              |
| `geometry.points`          | table\[]  | Vertices, each with `x`, `y` and `z`. `z` is the floor of the zone.                               |
| `geometry.thickness`       | number    | Height of the zone in metres.                                                                     |
| `metadata.maxSpeed`        | number    | Speed limit. `0` = no limit.                                                                      |
| `metadata.weapons`         | boolean   | `true` when weapons are allowed.                                                                  |
| `metadata.driveBy`         | boolean   | `true` when drive-by is allowed.                                                                  |
| `metadata.ControlsBlocked` | number\[] | Blocked control numbers.                                                                          |
| `metadata.bypass`          | table\[]  | Exceptions: `kind` (`'job'` or `'group'`), `value`, `skip`, and for jobs `minGrade` and `onDuty`. |
| `metadata.soundEnabled`    | boolean   | Enter and exit sound.                                                                             |
| `metadata.textUI`          | boolean   | `true` when the sign is shown.                                                                    |
| `metadata.debug`           | boolean   | `true` when the volume is drawn in the world.                                                     |
| `created_by`               | string    | License of the staff member who created it.                                                       |

{% hint style="info" %}
Treat the tables returned by the exports as read-only. Zones are changed from the panel.
{% endhint %}

## Events

Cuxial Safezones has no public events. Its events are internal and may change between versions.

## Player state

While a zone blocks weapons, the resource sets the player state bag `canUseWeapons` to `false`, and back to `true` on leaving. This is the state `ox_inventory` reads.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.cuxial.com/scripts/core/cuxial-safezones/developers.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
