Custom Job with Duty
Build a tow truck job with duty toggling, salary, and a custom uniform.
What You'll Build
- Tow truck job with three grades: Driver, Senior Driver, Supervisor
- Duty command that toggles on/off and changes the player's uniform
- Salary paid while on duty
/towcommand restricted to on-duty tow drivers
Prerequisites
shiva-jobsenabledshiva-economyenabled
Step 1 — Register the Job
lua
-- resources/[shiva]/shiva-jobs/config.lua
Config.jobs['towing'] = {
label = 'Towing Company',
defaultGrade = 0,
grades = {
[0] = { label = 'Driver', salary = 100 },
[1] = { label = 'Senior Driver', salary = 150 },
[2] = { label = 'Supervisor', salary = 200 },
},
}Step 2 — Create the Module
bash
shiva make module my-towingStep 3 — Duty Command
lua
-- server/init.lua
commands:register('towduty', {
description = 'Toggle towing duty',
permission = 'user',
handler = function(source)
local jobs = container:make('IJobs')
if not jobs:hasJob(source, 'towing') then
notify(source, 'error', 'You are not a tow driver.')
return
end
local onDuty = not jobs:isOnDuty(source)
jobs:setDuty(source, onDuty)
TriggerClientEvent('my-towing:dutyChanged', source, onDuty)
end
})Step 4 — Client Uniform
lua
-- client/init.lua
AddEventHandler('my-towing:dutyChanged', function(onDuty)
if onDuty then
-- Apply tow driver uniform
SetPedComponentVariation(PlayerPedId(), 11, 55, 0, 2) -- jacket
SetPedComponentVariation(PlayerPedId(), 4, 35, 0, 2) -- legs
else
-- Reset to civilian clothes
SetPedDefaultComponentVariation(PlayerPedId())
end
end)Step 5 — Restrict the Tow Command
lua
commands:register('tow', {
description = 'Tow a nearby vehicle',
permission = 'user',
handler = function(source)
local jobs = container:make('IJobs')
if not jobs:hasJob(source, 'towing') or not jobs:isOnDuty(source) then
notify(source, 'error', 'You must be on duty as a tow driver.')
return
end
-- tow logic
end,
})