Exports & Hooks
Bablo Electrician Job has a small public surface: two exports that return its configuration, and three server hooks in an open file that the script calls at fixed moments. Use the hooks to require a job, give XP or pay a bonus.
The script talks to your notification, clothing, vehicle key and target resources through open files you can edit. They are listed under Bridges.
Exports
Both exports work on the server and on the client.
GetConfig
Returns the Config table as the script uses it. Settings that were left on auto hold what was detected, for example Framework and Target.
local config = exports['bablo-electricjob']:GetConfig()
print(config.Command, config.Job.maxMembers)On the server, Config.Job.sites and Config.Job.orders also hold the boxes and routes from the Route Creator. Called from another resource, the table is a copy. Changing it does not change the script.
GetFramework
Returns the framework the script runs on: 'qbcore', 'qbox' or 'esx'. It returns nil when no framework was found.
local framework = exports['bablo-electricjob']:GetFramework()Hooks
The hooks are in frameworks/<framework>/server.lua, where <framework> is qbcore, qbox or esx. Only the file of your framework is used. Out of the box they allow everything and do nothing.
function Framework:canDoMission(source, orderId)
return true
end
function Framework:onFinishMinigame(source, data)
end
function Framework:onFinishMission(source, data)
endInside a hook, self is the framework bridge, so self:GetPlayer(source) and self:AddMoney(source, amount, account, reason) are available.
canDoMission
Decides whether a player may take electrician work. The script asks it at two moments:
| Moment | orderId |
|---|---|
| A player starts a work order: the crew leader, or a player working solo | The id of the route, for example 'la_mesa' |
| A player accepts a crew invite | nil, because a crew only takes new members while it has no work order |
Crew members who joined earlier are not asked again when the leader starts a route.
| Return | Result |
|---|---|
false, 'reason' | Blocked. The player sees the reason. |
false | Blocked with You cannot take electrician work right now. |
Anything else, also nil | Allowed. |
If the function throws an error, the player is blocked as well and the server console prints Framework:canDoMission errored with the error.
Example: only players with the electrician job may take work.
function Framework:canDoMission(source, orderId)
local player = self:GetPlayer(source)
local job = player and player.PlayerData.job
if not job or job.name ~= 'electrician' then
return false, 'You need to work for the power company.'
end
return true
endonFinishMinigame
Runs each time a cabinet or fuse box is restored. source is the player who repaired it. The hook only runs while that player is online.
| Field | Value |
|---|---|
siteId | The id of the box, for example 'supply_01' or an id from the Route Creator. |
title | The name of the box. |
orderId | The id of the route. |
repairKind | 'sequence' for a cabinet, 'fuse' for a fuse box. |
rounds | The number of rounds of a cabinet: 4 or 5, or 1 with Config.DEBUG = true. nil for a fuse box. |
assistantId | The server ID of the crewmate who was helping, or nil. See Helping a Crewmate. |
Example: give XP through your own XP script. your-xp and AddXP stand for your resource and its function.
function Framework:onFinishMinigame(source, data)
local xp = data.repairKind == 'fuse' and 20 or 10 * data.rounds
exports['your-xp']:AddXP(source, 'electrician', xp)
if data.assistantId then
exports['your-xp']:AddXP(data.assistantId, 'electrician', 5)
end
endonFinishMission
Runs when the crew leader has returned the van and the route is settled, after the payouts are handed out. It runs once for every crew member who is still online, with that member as source.
| Field | Value |
|---|---|
orderId | The id of the route. |
payout | This member’s share of the contract. |
account | The account it was paid to, Config.Currency.account ('bank' by default). |
crewSize | The number of members in the crew when the van was returned. |
leader | true for the crew leader who returned the van. |
Example: a bonus for the crew leader.
function Framework:onFinishMission(source, data)
if data.leader then
self:AddMoney(source, 250, data.account, 'electrician-leader-bonus')
end
endWhat onFinishMinigame and onFinishMission return is ignored. If one of them throws an error, the server console prints it and the job carries on. Payouts themselves are explained on Payouts.
Events and state
The script has no events that other resources are meant to use.
Every bablo-electricjob:* event and callback is internal traffic between the script’s own server and client. Don’t trigger them or rely on them.
The work van carries the state bag babloElectricVan with the id of its crew. It exists for the script itself.
Bridges
These files are not escrowed, so you can change which resource is called. All files you can open are shown in the Script Explorer.
| What | Resources | Where |
|---|---|---|
| Hooks | Your own code | canDoMission, onFinishMinigame and onFinishMission in frameworks/<framework>/server.lua |
| Money | The player’s framework account | Framework:AddMoney in frameworks/<framework>/server.lua |
| Character | The citizen ID and character name on QBCore and Qbox, the identifier and name on ESX | Framework:GetIdentifier and Framework:getPlayerName in frameworks/<framework>/server.lua |
| Notifications | Your framework, ox_lib or GTA’s feed | frameworks/notification/client.lua |
| Work outfit | GTA clothing natives | frameworks/outfit/client.lua, see Work Outfit |
| Vehicle keys | Seven key resources, see below | frameworks/vehiclekeys/client.lua |
| Target | ox_target, qb-target, or an E prompt without a target script | src/interactions/ox_target.lua, qb-target.lua and standalone.lua, picked with Config.Target |
Notifications
Config.Notify chooses where messages go:
| Value | Result |
|---|---|
'framework' | The notification of QBCore, Qbox or ESX. When that fails, or no framework was found, GTA’s feed is used. This is the default. |
'ox_lib' | lib.notify from ox_lib. |
'gta' | GTA’s notification feed. |
To use another notification resource, change ElectricNotification(message, kind, duration) in frameworks/notification/client.lua. kind is 'info', 'success' or 'error'.
While a player is repairing a box, messages are not sent as notifications. On a cabinet they show on the panel monitor instead.
Vehicle keys
When the crew’s van is out, every crew member’s client gives itself the keys through the first of these resources that is started:
| Order | Resource | How the key is given |
|---|---|---|
| 1 | qbx_vehiclekeys | The server gives the keys through its GiveKeys export. |
| 2 | Renewed-Vehiclekeys | addKey(plate) |
| 3 | wasabi_carlock | GiveKey(plate) |
| 4 | qs-vehiclekeys | GiveKeys(plate) |
| 5 | tgiann-hotwire | The tgiann-hotwire:addKey event |
| 6 | cd_garage | The cd_garage:AddKeys event |
| 7 | qb-vehiclekeys | The vehiclekeys:client:SetOwner event |
When none of them is started, no key is given. When the call fails, the client console prints that the resource rejected the key handoff.
To use another key resource, add an entry at the top of the handlers list in frameworks/vehiclekeys/client.lua:
{ resource = 'my-keys', give = function(plate, vehicle) exports['my-keys']:GiveKey(plate) end },See Work Van for the van itself.

