-
Notifications
You must be signed in to change notification settings - Fork 18
/
cl_jobs.lua
87 lines (83 loc) · 3.1 KB
/
cl_jobs.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
local Config = lib.require('config')
local function showMultijob()
local PlayerData = QBCore.Functions.GetPlayerData()
local dutyStatus = PlayerData.job.onduty and 'On Duty' or 'Off Duty'
local dutyIcon = PlayerData.job.onduty and 'fa-solid fa-toggle-on' or 'fa-solid fa-toggle-off'
local colorIcon = PlayerData.job.onduty and '#5ff5b4' or 'red'
local jobMenu = {
id = 'job_menu',
title = 'My Jobs',
options = {
{
title = 'Toggle Duty',
description = 'Current Status: ' .. dutyStatus,
icon = dutyIcon,
iconColor = colorIcon,
onSelect = function()
TriggerServerEvent('QBCore:ToggleDuty')
Wait(500)
showMultijob()
end,
},
},
}
local myJobs = lib.callback.await('randol_multijob:server:myJobs', false)
if myJobs then
for _, job in ipairs(myJobs) do
local isDisabled = PlayerData.job.name == job.job
jobMenu.options[#jobMenu.options + 1] = {
title = job.jobLabel,
description = ('Grade: %s [%s]\nSalary: $%s'):format(job.gradeLabel, tonumber(job.grade), job.salary),
icon = Config.JobIcons[job.job] or 'fa-solid fa-briefcase',
arrow = true,
disabled = isDisabled,
event = 'randol_multijob:client:choiceMenu',
args = {jobLabel = job.jobLabel, job = job.job, grade = job.grade},
}
end
lib.registerContext(jobMenu)
lib.showContext('job_menu')
end
end
AddEventHandler('randol_multijob:client:choiceMenu', function(args)
local displayChoices = {
id = 'choice_menu',
title = 'Job Actions',
menu = 'job_menu',
options = {
{
title = 'Switch Job',
description = ('Switch your job to: %s'):format(args.jobLabel),
icon = 'fa-solid fa-circle-check',
onSelect = function()
TriggerServerEvent('randol_multijob:server:changeJob', args.job)
Wait(100)
showMultijob()
end,
},
{
title = 'Delete Job',
description = ('Delete the selected job: %s'):format(args.jobLabel),
icon = 'fa-solid fa-trash-can',
onSelect = function()
TriggerServerEvent('randol_multijob:server:deleteJob', args.job)
Wait(100)
showMultijob()
end,
},
}
}
lib.registerContext(displayChoices)
lib.showContext('choice_menu')
end)
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo)
TriggerServerEvent('randol_multijob:server:newJob', JobInfo)
end)
lib.addKeybind({
name = 'myjobs',
description = 'Multi Job',
defaultKey = 'F10',
onPressed = function(self)
showMultijob()
end
})