Open Hooks
Two open files let you change what happens at key moments without touching escrowed code.
Server, server/open/hooks.lua
Rewards are paid here, using Config.Rewards. Edit freely.
| Hook | Called when |
|---|---|
Hooks.OnShiftStart(src, serviceId) | A shift starts |
Hooks.OnShiftEnd(src, serviceId, seconds) | A shift ends, with its length |
Hooks.OnCalloutStarted(src, callout) | A callout is accepted |
Hooks.OnCalloutCompleted(src, callout) | A callout is completed. Pays calloutComplete |
Hooks.OnArrest(src, data) | A suspect is arrested. Pays arrest |
Hooks.OnCitation(src, data) | A citation is issued. Pays citation |
Hooks.OnPatientDelivered(src, record) | A patient is handed over. Pays patientDelivered |
Hooks.OnPursuitStarted(src, person, plate) | A pursuit starts |
Hooks.BusyElsewhere(src) | Before offers and shift starts: return a locale key if the player is busy in another script |
callout is { uid, calloutId, label, code, street, coords, startedAt, assist }. assist is the service when the player assisted someone else's joint callout.
Example: pay more for priority 1 callouts
function Hooks.OnCalloutCompleted(src, callout)
local amount = Config.Rewards.calloutComplete
for _, def in ipairs(Config.Callouts.list) do
if def.id == callout.calloutId and def.priority == 1 then amount = amount * 2 end
end
reward(src, amount, callout.label)
endExample: pay into a society account
Replace the reward function's body with your banking script's export, for example a society deposit instead of Bridge.Framework.AddMoney.
Busy in another script
Hooks.BusyElsewhere checks kartik-ambulancejob (HasActiveAICallout) and kartik-firefighterjob (IsOnNpcMission). Add your own script to the busyChecks list:
{ resource = 'my-job', export = 'IsOnMission', reason = 'busy_ems_job' },Client, client/open/functions.lua
| Function | What it does |
|---|---|
GetPostal(coords) | Postal code next to street names. Uses nearest-postal if it runs. Return nil to hide |
CanOpenTablet() | Whether the player may open the tablet, e.g. require an item |
OnSuspectArrested(ped, record) | Called after an arrest |
OnTrafficStopStarted(driver, vehicle, driverRecord, vehicleRecord) | Called when a traffic stop starts |
Example: require a tablet item
function CanOpenTablet()
if IsPauseMenuActive() then return false end
return exports.ox_inventory:Search('count', 'tablet') > 0
end