F5 StudioF5 Studio
Skip to main content

Exports & Events

Client Exports

IsPlayerInSafezone

Returns whether the local player is currently inside a safezone.

Client-side
local inSafezone = exports['f5_safezones']:IsPlayerInSafezone()
-- Returns: boolean

GetCurrentSafezone

Returns the zone data table for the current safezone, or nil if not in one.

Client-side
local zone = exports['f5_safezones']:GetCurrentSafezone()
if zone then
print(zone.name) -- "Legion Square"
print(zone.type) -- "circle" or "polygon"
print(zone.radius) -- 50.0 (circle only)
end
-- Returns: table | nil

GetAllZones

Returns a table of all currently loaded zones (both config and custom).

Client-side
local zones = exports['f5_safezones']:GetAllZones()
for _, zone in ipairs(zones) do
print(zone.name, zone.type)
end
-- Returns: table

IsPlayerInGhostMode

Returns whether the local player is currently in ghost mode (in a safezone with ghosting enabled).

Client-side
local ghosted = exports['f5_safezones']:IsPlayerInGhostMode()
-- Returns: boolean

GetPerformanceStats

Returns performance metrics for the safezone system.

Client-side
local stats = exports['f5_safezones']:GetPerformanceStats()
print(stats.avgCheckTime) -- Average zone check time (ms)
print(stats.lastZoneCheck) -- Last check duration (ms)
print(stats.checkCount) -- Total checks performed
print(stats.frameTime) -- Frame time tracking
print(stats.markerRenderTime) -- Marker render time (ms)
print(stats.collisionUpdateTime) -- Collision system time (ms)
print(stats.vehiclesProcessed) -- Vehicles being tracked
print(stats.playersGhosted) -- Players currently ghosted
-- Returns: table

IsDebugModeActive

Returns whether debug visualization is currently enabled.

Client-side
local debug = exports['f5_safezones']:IsDebugModeActive()
-- Returns: boolean

GetLowestPointInZone

Returns the lowest ground Z coordinate within a named zone. Useful for placing objects or markers at ground level.

Client-side
local lowestZ = exports['f5_safezones']:GetLowestPointInZone("Legion Square")
-- Returns: number | nil

GetCollisionEntities

Returns the table of entities currently being tracked by the collision system.

Client-side
local entities = exports['f5_safezones']:GetCollisionEntities()
-- Returns: table (keyed by entity handle)

GetGhostedVehicles

Returns a table of vehicles currently ghosted for the local player.

Client-side
local vehicles = exports['f5_safezones']:GetGhostedVehicles()
-- Returns: table (keyed by vehicle handle)

GetGhostedPlayers

Returns a table of players currently ghosted for the local player.

Client-side
local players = exports['f5_safezones']:GetGhostedPlayers()
-- Returns: table (keyed by server ID)

GetPlayersInCurrentZone

Returns a table of other players in the same safezone as the local player.

Client-side
local players = exports['f5_safezones']:GetPlayersInCurrentZone()
-- Returns: table (keyed by server ID)

Server Exports

IsPlayerInSafezone

Check if a player (by server ID) is currently in a safezone.

Server-side
local inZone = exports['f5_safezones']:IsPlayerInSafezone(playerId)
-- Returns: boolean

GetPlayerSafezoneInfo

Get detailed information about a player's current safezone status.

Server-side
local info = exports['f5_safezones']:GetPlayerSafezoneInfo(playerId)
if info then
print(info.zoneName) -- "Legion Square"
print(info.enteredAt) -- Unix timestamp
print(info.timeInZone) -- Seconds spent in zone
end
-- Returns: table | nil

GetAllPlayersInSafezones

Returns a table of all players currently in safezones.

Server-side
local players = exports['f5_safezones']:GetAllPlayersInSafezones()
for playerId, info in pairs(players) do
print(playerId, info.zoneName, info.timeInZone)
end
-- Returns: table (keyed by server ID)

GetAllSafezones

Returns a table of all safezone definitions (both config and custom).

Server-side
local zones = exports['f5_safezones']:GetAllSafezones()
-- Returns: table

GetPlayersInSpecificZone

Returns a list of players in a specific named zone.

Server-side
local players = exports['f5_safezones']:GetPlayersInSpecificZone("Legion Square")
for _, player in ipairs(players) do
print(player.playerId, player.playerName, player.timeInZone)
end
-- Returns: table (array of player info tables)

Client Events

Show Notification

Sends a notification to a specific player using their framework's notification system (QBCore.Functions.Notify, ox_lib, ESX.ShowNotification). Can be used from server-side scripts to notify players.

Server-side
TriggerClientEvent('f5_safezones:showNotification', playerId, message, notifType)
-- notifType: 'success', 'error', 'primary' (default)

Player Entered Zone

Fired when the local player enters a safezone.

Client-side
AddEventHandler('f5_safezones:enteredZone', function(zone)
print('Entered safezone: ' .. zone.name)
print('Zone type: ' .. zone.type)
-- zone contains the full zone data table
end)

Player Exited Zone

Fired when the local player exits a safezone.

Client-side
AddEventHandler('f5_safezones:exitedZone', function(zoneName)
print('Left safezone: ' .. zoneName)
end)

Server Events

Player Entered Zone

Fired on the server when any player enters a safezone (after server-side verification).

Server-side
AddEventHandler('f5_safezones:playerEntered', function(playerId, zoneName)
print(GetPlayerName(playerId) .. ' entered ' .. zoneName)
end)

Player Exited Zone

Fired on the server when any player exits a safezone.

Server-side
AddEventHandler('f5_safezones:playerExited', function(playerId, zoneName, timeInZone)
print(GetPlayerName(playerId) .. ' left ' .. zoneName .. ' after ' .. timeInZone .. 's')
end)

Zone Created

Fired on the server when an admin creates a new zone.

Server-side
AddEventHandler('f5_safezones:zoneCreated', function(data)
print(data.adminName .. ' created zone: ' .. data.zone.name)
-- data.admin = server ID of the admin
-- data.adminName = admin player name
-- data.zone = full zone data table
end)

Zone Updated

Fired on the server when an admin modifies a zone.

Server-side
AddEventHandler('f5_safezones:zoneUpdated', function(data)
print(data.adminName .. ' updated zone: ' .. data.newZone.name)
-- data.admin = server ID of the admin
-- data.adminName = admin player name
-- data.oldZone = zone data before update
-- data.newZone = zone data after update
end)

Zone Deleted

Fired on the server when an admin deletes a zone.

Server-side
AddEventHandler('f5_safezones:zoneDeleted', function(data)
print(data.adminName .. ' deleted zone: ' .. data.zone.name .. ' (' .. data.playersAffected .. ' players affected)')
-- data.admin = server ID of the admin
-- data.adminName = admin player name
-- data.zone = deleted zone data
-- data.playersAffected = number of players who were in the zone
end)

Integration Examples

Disable Robbery in Safezones

Client-side — your robbery script
-- Before starting a robbery, check if player is in a safezone
RegisterCommand('rob', function()
if exports['f5_safezones']:IsPlayerInSafezone() then
-- Use your framework's notification system
print('You cannot rob in a safe zone!')
return
end

-- Proceed with robbery logic
StartRobbery()
end)

Log Safezone Activity

Server-side — your logging script
AddEventHandler('f5_safezones:playerEntered', function(playerId, zoneName)
-- Log to your external logging system (Discord, database, etc.)
local playerName = GetPlayerName(playerId)
SendToDiscordLog(string.format('%s entered safezone: %s', playerName, zoneName))
end)

AddEventHandler('f5_safezones:playerExited', function(playerId, zoneName, timeInZone)
local playerName = GetPlayerName(playerId)
SendToDiscordLog(string.format('%s left %s after %d seconds', playerName, zoneName, timeInZone))
end)

Prevent Vehicle Spawning in Safezones

Server-side — your garage/vehicle script
RegisterNetEvent('mygarage:spawnVehicle', function(vehicleModel, plate)
local src = source

if exports['f5_safezones']:IsPlayerInSafezone(src) then
-- Use your framework's notification system
TriggerClientEvent('f5_safezones:showNotification', src, 'You cannot spawn vehicles in a safe zone.', 'error')
return
end

-- Proceed with vehicle spawn
SpawnVehicleForPlayer(src, vehicleModel, plate)
end)

HUD Integration

Client-side — your HUD script
-- Show a safezone indicator on your HUD
CreateThread(function()
while true do
local inZone = exports['f5_safezones']:IsPlayerInSafezone()
local zoneName = nil

if inZone then
local zone = exports['f5_safezones']:GetCurrentSafezone()
zoneName = zone and zone.name or 'Unknown'
end

SendNUIMessage({
action = 'updateSafezoneStatus',
inSafezone = inZone,
zoneName = zoneName
})

Wait(1000)
end
end)

Check Ghost Mode for Custom Features

Client-side
-- Disable certain actions when player is ghosted
CreateThread(function()
while true do
if exports['f5_safezones']:IsPlayerInGhostMode() then
-- Player is ghosted — disable trading, item dropping, etc.
DisableTrading()
end
Wait(1000)
end
end)

Server-Side Zone Monitoring Dashboard

Server-side
-- Get a snapshot of all safezone activity
RegisterCommand('zonestats', function(source)
local allPlayers = exports['f5_safezones']:GetAllPlayersInSafezones()
local allZones = exports['f5_safezones']:GetAllSafezones()

local playerCount = 0
for _ in pairs(allPlayers) do playerCount = playerCount + 1 end

print('^2[Safezones]^0 Total zones: ' .. #allZones)
print('^2[Safezones]^0 Players in zones: ' .. playerCount)

for playerId, info in pairs(allPlayers) do
print(string.format(' - %s (ID %d) in "%s" for %ds',
GetPlayerName(playerId), playerId, info.zoneName, info.timeInZone))
end
end, true)
info

All exports and events work identically across all supported frameworks. The framework abstraction is handled internally by the resource.

See Also