> For the complete documentation index, see [llms.txt](https://viper-development-1.gitbook.io/viperdocs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://viper-development-1.gitbook.io/viperdocs/viper-scripts/safe-zone/developer-api/client-exports.md).

# Client Exports

Client-side exports for viper-safezones.

All client exports are called on viper-safezones.

```lua
exports["viper-safezones"]:ExportName(...)
```

## Quick reference

<table data-search="false"><thead><tr><th>Export</th><th>Description</th></tr></thead><tbody><tr><td><a href="#isinsafezone">IsInSafeZone</a></td><td>Whether the local player is currently in a safe zone</td></tr><tr><td><a href="#getactiverestrictions">GetActiveRestrictions</a></td><td>The restrictions currently applied to the local player</td></tr><tr><td><a href="#getcurrentzoneids">GetCurrentZoneIds</a></td><td>IDs of every zone the local player is inside</td></tr><tr><td><a href="#isplacing">IsPlacing</a></td><td>Whether the local player is in zone placement mode</td></tr><tr><td><a href="#getzone">GetZone</a></td><td>Get a single zone by its ID</td></tr><tr><td><a href="#getallzones">GetAllZones</a></td><td>Get every zone loaded on the client</td></tr><tr><td><a href="#ispointinsafezone">IsPointInSafeZone</a></td><td>Check if coordinates fall inside a zone</td></tr></tbody></table>

***

## Zone state

{% hint style="success" %}

#### IsInSafeZone

Check if the local player is currently inside any safe zone.

```lua
---@return boolean
local inZone = exports["viper-safezones"]:IsInSafeZone()
```

{% endhint %}

{% hint style="success" %}

#### GetActiveRestrictions

Get the restrictions currently applied to the local player. When standing in overlapping zones, every enabled restriction applies and the lowest speed limit wins.

```lua
---@class Restrictions
---@field disableWeapons boolean # Firearms are blocked
---@field noFists boolean # Melee and fists are blocked
---@field invincible boolean # Player cannot take damage
---@field speedKmh number # Vehicle speed limit, 0 means no limit

---@return Restrictions
local restrictions = exports["viper-safezones"]:GetActiveRestrictions()
```

{% endhint %}

{% hint style="success" %}

#### GetCurrentZoneIds

Get the IDs of every zone the local player is inside. Returns more than one entry when zones overlap, or an empty table when outside all zones.

```lua
---@return number[]
local ids = exports["viper-safezones"]:GetCurrentZoneIds()
```

{% endhint %}

{% hint style="success" %}

#### IsPlacing

Check if the local player is currently in zone placement mode. Useful if your script needs to disable itself while an admin is drawing a zone.

```lua
---@return boolean
local placing = exports["viper-safezones"]:IsPlacing()
```

{% endhint %}

## Zone data

{% hint style="success" %}

#### GetZone

Get a single zone by its ID.

```lua
---@param id number
---@return Zone? # nil if the zone does not exist
local zone = exports["viper-safezones"]:GetZone(id)
```

{% endhint %}

{% hint style="success" %}

#### GetAllZones

Get every zone loaded on the client.

```lua
---@return Zone[]
local zones = exports["viper-safezones"]:GetAllZones()
```

{% endhint %}

{% hint style="success" %}

#### IsPointInSafeZone

Check if coordinates fall inside a zone. Pass an ID to test one specific zone, or leave it out to test every zone.

```lua
---@param coords vector3 | { x: number, y: number, z: number }
---@param id? number # Test only this zone, omit to test all zones
---@return boolean
local inside = exports["viper-safezones"]:IsPointInSafeZone(coords, id)
```

{% endhint %}
