Exports & events
On this page
State bags
On the vehicle, readable on every client and the server:
Lua
Entity(vehicle).state.pursuitMode -- 'A', 'B', 'C' or nil when off
Entity(vehicle).state.pursuitUnit -- server id of the officer who set itOn the player: LocalPlayer.state.pursuitAllowed is true while the player counts as police.
Events
Lua
-- client, on every client that has the vehicle
AddEventHandler('saf-pursuit:modeChanged', function(vehicle, mode, oldMode) end)
-- server
AddEventHandler('saf-pursuit:modeChanged', function(vehicle, mode, oldMode, src) end)
AddEventHandler('saf-pursuit:pit', function(src, vehicle, target, side) end)Client exports
Lua
exports['saf-pursuit']:GetMode(vehicle) -- 'OFF', 'A', 'B', 'C' (your current car if vehicle is nil)
exports['saf-pursuit']:IsInPursuit(vehicle) -- true in a mode marked Pursuit (B and C by default)
exports['saf-pursuit']:SetMode('C') -- asks for a mode on the car you drive, same checks as the keyServer exports
Lua
exports['saf-pursuit']:GetMode(vehicle) -- vehicle entity or network id
exports['saf-pursuit']:IsInPursuit(vehicle)
exports['saf-pursuit']:SetMode(vehicle, 'B') -- no police checks; a player must be driving
exports['saf-pursuit']:GetUnits() -- { vehicle, netId, source, mode, plate } for every car with a modeExample: flag units in pursuit on your CAD
Lua
-- in your own server resource
AddEventHandler('saf-pursuit:modeChanged', function(vehicle, mode, oldMode, src)
local inPursuit = mode == 'B' or mode == 'C'
exports['my-cad']:SetUnitStatus(src, inPursuit and 'PURSUIT' or 'AVAILABLE')
end)Example: list active units
Lua
for _, unit in ipairs(exports['saf-pursuit']:GetUnits()) do
print(('%s in mode %s, driven by %s'):format(unit.plate, unit.mode, unit.source))
end