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

Lua
exports.gg_towjob:RequestPoliceImpoundTow(payload)
PayloadMeaning
Vehicle entity or network idThe vehicle to impound
Table with vehicle, entity, vehicle_netid or netidThe same, from a target or menu callback
nilThe 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.

Lua
-- an ox_target option on vehicles
onSelect = function(data)
    exports.gg_towjob:RequestPoliceImpoundTow(data.entity)
end,

Server

Lua
local ok, message = exports.gg_towjob:RequestPoliceImpoundTow(source, payload)
ParameterTypeMeaning
sourcenumberThe officer's server id
payloadnumber or tableThe vehicle's network id, or { vehicle_netid = netid }
ReturnsTypeMeaning
okbooleantrue when the contract was posted
messagestringThe 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

Lua
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:

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:

Lua
hooks.jobCompleted = function(source, payload)
end

Runs on the server once for each player who is paid for a contract.

FieldTypeMeaning
payload.jobtableThe contract type from cfg.jobs.types
payload.group_idnumberThe player's group
payload.claimer_sourcenumberThe player who claimed the contract
payload.payout.moneynumberMoney paid to this player
payload.payout.experiencenumberXP given to this player
payload.payout.itemstableThe contract's item rewards

Support

Questions before you buy?

Ask the team in our Discord before you pay a thing. Setup help, update notes, giveaways and discount codes, all in one place.

831 online now2,241 members