Exports and hooks
Request police impound tows, open the towing tablet, and run your own code on menu access and finished contracts.
These exports, events and hooks are in the files that ship open in gg_towjob/base/core/open/.
Request a police impound tow
The player who requests the tow must have a job in police_impound.jobs and stand within police_impound.max_distance (8 metres) of the vehicle. The vehicle must be player owned and not already on a tow contract.
Client
exports.gg_towjob:RequestPoliceImpoundTow(payload)
| Payload | Meaning |
|---|---|
| Vehicle entity or network id | The vehicle to impound |
Table with vehicle, entity, vehicle_netid or netid | The same, from a target or menu callback |
nil | The closest vehicle within range |
The player gets a notification with the result. The same request runs from the client event gg_towjob:client:requestPoliceImpoundTow with the same payload.
-- an ox_target option on vehicles
onSelect = function(data)
exports.gg_towjob:RequestPoliceImpoundTow(data.entity)
end,
Server
local ok, message = exports.gg_towjob:RequestPoliceImpoundTow(source, payload)
| Parameter | Type | Meaning |
|---|---|---|
source | number | The officer's server id |
payload | number or table | The vehicle's network id, or { vehicle_netid = netid } |
| Returns | Type | Meaning |
|---|---|---|
ok | boolean | true when the contract was posted |
message | string | The result text, for example "Vehicle plate was not found in the ownership database." |
From a client you can also send the server event gg_towjob:server:policeImpound:request with the same payload. The officer is notified with the result.
Open the towing tablet
exports.gg_towjob:OpenTowingTablet()
Opens the contracts tablet for the local player, the same as using gg_towing_tablet. The client event gg_towjob:client:openTablet does the same.
Hooks
Edit these functions in place. An update replaces these files, so keep a copy of your changes.
Who can open the menu
base/core/open/client/hooks.lua:
hooks.canOpenMenu = function()
return true
end
Runs before the job menu opens at the attendant. Return false to stop it, for example to check a grade or a licence.
When a contract is completed
base/core/open/server/hooks.lua:
hooks.jobCompleted = function(source, payload)
end
Runs on the server once for each player who is paid for a contract.
| Field | Type | Meaning |
|---|---|---|
payload.job | table | The contract type from cfg.jobs.types |
payload.group_id | number | The player's group |
payload.claimer_source | number | The player who claimed the contract |
payload.payout.money | number | Money paid to this player |
payload.payout.experience | number | XP given to this player |
payload.payout.items | table | The contract's item rewards |
