Skip to content

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, 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()

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.

lua
exports.cuxial_safezones:CloseZonesUI()

IsDriveByBlocked ​

Tells whether the zone the local player is in blocks drive-by.

lua
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.

lua
local zones = exports.cuxial_safezones:GetSafeZones()

Returns: table<number, table>. Zone objects 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)
ParameterTypeDescription
idnumberZone id.

Returns: table | nil.

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

Zone object ​

FieldTypeDescription
idnumberZone id.
labelstringZone name.
activebooleanfalse when the zone is turned off.
geometry.pointstable[]Vertices, each with x, y and z. z is the floor of the zone.
geometry.thicknessnumberHeight of the zone in metres.
metadata.maxSpeednumberSpeed limit. 0 = no limit.
metadata.weaponsbooleantrue when weapons are allowed.
metadata.driveBybooleantrue when drive-by is allowed.
metadata.ControlsBlockednumber[]Blocked control numbers.
metadata.bypasstable[]Exceptions: kind ('job' or 'group'), value, skip, and for jobs minGrade and onDuty.
metadata.soundEnabledbooleanEnter and exit sound.
metadata.textUIbooleantrue when the sign is shown.
metadata.debugbooleantrue when the volume is drawn in the world.
created_bystringLicense 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.

© Cuxial