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.
local inside = exports.cuxial_safezones:IsInSafeZone()Returns: boolean. It is true inside the zone even when an exception lets the player skip its rules.
if exports.cuxial_safezones:IsInSafeZone() then
return lib.notify({ description = 'Not inside a safe zone.', type = 'error' })
endGetCurrentSafeZone
Returns the zone the local player is in.
local zone = exports.cuxial_safezones:GetCurrentSafeZone()Returns: table | nil. A zone object, or nil outside any zone.
local zone = exports.cuxial_safezones:GetCurrentSafeZone()
if zone then print(zone.id, zone.label) endOpenZonesUI
Opens the zone panel for the local player.
exports.cuxial_safezones:OpenZonesUI()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.
CloseZonesUI
Closes the panel.
exports.cuxial_safezones:CloseZonesUI()IsDriveByBlocked
Tells whether the zone the local player is in blocks drive-by.
local blocked = exports.cuxial_safezones:IsDriveByBlocked()Returns: boolean. true when the player is inside a zone that blocks shooting from a vehicle and no exception lets them skip it.
Server exports
GetSafeZones
Returns every zone, including the ones turned off.
local zones = exports.cuxial_safezones:GetSafeZones()Returns: table<number, table>. Zone objects indexed by zone id.
for id, zone in pairs(exports.cuxial_safezones:GetSafeZones()) do
print(id, zone.label, zone.active)
endGetSafeZone
Returns one zone.
local zone = exports.cuxial_safezones:GetSafeZone(id)| Parameter | Type | Description |
|---|---|---|
id | number | Zone id. |
Returns: table | nil.
local zone = exports.cuxial_safezones:GetSafeZone(3)
if zone and zone.active then print(zone.label) endZone 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. |
Treat the tables returned by the exports as read-only. Zones are changed from the panel.
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.
