Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 40 additions & 38 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,60 @@ Config = Config or {}
-- Side of the screen where you want the ui to be on. Can either be "left" or "right"
Config.Side = "right"

Config.Core = 'qbox' -- qbox or qb-core

Config.MaxJobs = 3
Config.IgnoredJobs = {
["unemployed"] = true,
["unemployed"] = true,
}

Config.DenyDuty = {
["ambulance"] = true,
["police"] = true,
["ambulance"] = true,
["police"] = true,
}

Config.WhitelistJobs = {
["police"] = true,
["ambulance"] = true,
["mechanic"] = true,
["judge"] = true,
["lawyer"] = true,
["police"] = true,
["ambulance"] = true,
["mechanic"] = true,
["judge"] = true,
["lawyer"] = true,
}

Config.Descriptions = {
["police"] = "Shoot some criminals or maybe be a good cop and arrest them",
["ambulance"] = "Fix the bullet holes",
["mechanic"] = "Fix the bullet holes",
["tow"] = "Pickup the tow truck and steal some vehicles",
["taxi"] = "Pickup people around the city and drive them to their destination",
["bus"] = "Pickup multiple people around the city and drive them to their destination",
["realestate"] = "Sell houses or something",
["cardealer"] = "Sell cars or something",
["judge"] = "Decide if people are guilty",
["lawyer"] = "Help the good or the bad",
["reporter"] = "Lowkey useless",
["trucker"] = "Drive a truck",
["garbage"] = "Drive a garbage truck",
["vineyard"] = "Get them vines",
["hotdog"] = "Sell them glizzys",
["police"] = "Shoot some criminals or maybe be a good cop and arrest them",
["ambulance"] = "Fix the bullet holes",
["mechanic"] = "Fix the bullet holes",
["tow"] = "Pickup the tow truck and steal some vehicles",
["taxi"] = "Pickup people around the city and drive them to their destination",
["bus"] = "Pickup multiple people around the city and drive them to their destination",
["realestate"] = "Sell houses or something",
["cardealer"] = "Sell cars or something",
["judge"] = "Decide if people are guilty",
["lawyer"] = "Help the good or the bad",
["reporter"] = "Lowkey useless",
["trucker"] = "Drive a truck",
["garbage"] = "Drive a garbage truck",
["vineyard"] = "Get them vines",
["hotdog"] = "Sell them glizzys",
}

-- Change the icons to any free font awesome icon, also add other jobs your server might have to the list
-- List: https://fontawesome.com/search?o=r&s=solid
Config.FontAwesomeIcons = {
["police"] = "fa-solid fa-handcuffs",
["ambulance"] = "fa-solid fa-user-doctor",
["mechanic"] = "fa-solid fa-wrench",
["tow"] = "fa-solid fa-truck-tow",
["taxi"] = "fa-solid fa-taxi",
["bus"] = "fa-solid fa-bus",
["realestate"] = "fa-solid fa-sign-hanging",
["cardealer"] = "fa-solid fa-cards",
["judge"] = "fa-solid fa-gave",
["lawyer"] = "fa-solid fa-gavel",
["reporter"] = "fa-solid fa-microphone",
["trucker"] = "fa-solid fa-truck-front",
["garbage"] = "fa-solid fa-trash-can",
["vineyard"] = "fa-solid fa-wine-bottle",
["hotdog"] = "fa-solid fa-hotdog",
["police"] = "fa-solid fa-handcuffs",
["ambulance"] = "fa-solid fa-user-doctor",
["mechanic"] = "fa-solid fa-wrench",
["tow"] = "fa-solid fa-truck-tow",
["taxi"] = "fa-solid fa-taxi",
["bus"] = "fa-solid fa-bus",
["realestate"] = "fa-solid fa-sign-hanging",
["cardealer"] = "fa-solid fa-cards",
["judge"] = "fa-solid fa-gave",
["lawyer"] = "fa-solid fa-gavel",
["reporter"] = "fa-solid fa-microphone",
["trucker"] = "fa-solid fa-truck-front",
["garbage"] = "fa-solid fa-trash-can",
["vineyard"] = "fa-solid fa-wine-bottle",
["hotdog"] = "fa-solid fa-hotdog",
}
136 changes: 97 additions & 39 deletions server/sv_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -196,51 +196,109 @@ QBCore.Commands.Add('addjob', 'Add Multi Job (Admin Only)', { { name = 'id', hel
end, 'admin')

QBCore.Functions.CreateCallback("ps-multijob:getJobs", function(source, cb)
local Player = QBCore.Functions.GetPlayer(source)
local jobs = GetJobs(Player.PlayerData.citizenid)
local multijobs = {}
local whitelistedjobs = {}
local civjobs = {}
local active = {}
local getjobs = {}
local Players = QBCore.Functions.GetPlayers()

for i = 1, #Players, 1 do
local xPlayer = QBCore.Functions.GetPlayer(Players[i])
active[xPlayer.PlayerData.job.name] = 0
if active[xPlayer.PlayerData.job.name] and xPlayer.PlayerData.job.onduty then
active[xPlayer.PlayerData.job.name] = active[xPlayer.PlayerData.job.name] + 1
if Config.Core == 'qbox' then
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return cb({ whitelist = {}, civilian = {} }) end

local jobs = GetJobs(Player.PlayerData.citizenid)
local multijobs = {
whitelist = {},
civilian = {}
}
local active = {}

local Players = QBCore.Functions.GetPlayers()
for _, playerId in pairs(Players) do
local xPlayer = QBCore.Functions.GetPlayer(playerId)
if xPlayer then
local jobName = xPlayer.PlayerData.job.name
if not active[jobName] then
active[jobName] = 0
end
if xPlayer.PlayerData.job.onduty then
active[jobName] = active[jobName] + 1
end
end
end
end

for job, grade in pairs(jobs) do
if QBCore.Shared.Jobs[job] == nil then
print("The job '" .. job .. "' has been removed and is not present in your QBCore jobs. Remove it from the multijob SQL or add it back to your qbcore jobs.lua.")
else
local online = active[job] or 0
getjobs = {
name = job,
grade = grade,
description = Config.Descriptions[job],
icon = Config.FontAwesomeIcons[job],
label = QBCore.Shared.Jobs[job].label,
gradeLabel = QBCore.Shared.Jobs[job].grades[tostring(grade)].name,
salary = QBCore.Shared.Jobs[job].grades[tostring(grade)].payment,
active = online,
}
if Config.WhitelistJobs[job] then
whitelistedjobs[#whitelistedjobs+1] = getjobs
for job, grade in pairs(jobs) do
local jobData = QBCore.Shared.Jobs[job]
if not jobData then
print("^1[ps-multijob] The job '" .. job .. "' is missing from Shared.Jobs. Remove it from the multijob SQL or add it back to jobs.lua.^0")
else
civjobs[#civjobs+1] = getjobs
local jobGrade = jobData.grades[tostring(grade)] or jobData.grades[grade]
-- local jobGrade = jobData.grades[tostring(grade)]
if jobGrade then
local jobInfo = {
name = job,
grade = grade,
description = Config.Descriptions[job] or "",
icon = Config.FontAwesomeIcons[job] or "",
label = jobData.label or job,
gradeLabel = jobGrade.name or "Unknown",
salary = jobGrade.payment or 0,
active = active[job] or 0,
}

if Config.WhitelistJobs[job] then
table.insert(multijobs.whitelist, jobInfo)
else
table.insert(multijobs.civilian, jobInfo)
end
else
print("^1[ps-multijob] Grade " .. grade .. " not found for job '" .. job .. "'.^0")
end
end
end
end

multijobs = {
whitelist = whitelistedjobs,
civilian = civjobs,
}
cb(multijobs)
cb(multijobs)
elseif Config.Core == 'qb-core' then
local Player = QBCore.Functions.GetPlayer(source)
local jobs = GetJobs(Player.PlayerData.citizenid)
local multijobs = {}
local whitelistedjobs = {}
local civjobs = {}
local active = {}
local getjobs = {}
local Players = QBCore.Functions.GetPlayers()

for i = 1, #Players, 1 do
local xPlayer = QBCore.Functions.GetPlayer(Players[i])
active[xPlayer.PlayerData.job.name] = 0
if active[xPlayer.PlayerData.job.name] and xPlayer.PlayerData.job.onduty then
active[xPlayer.PlayerData.job.name] = active[xPlayer.PlayerData.job.name] + 1
end
end

for job, grade in pairs(jobs) do
if QBCore.Shared.Jobs[job] == nil then
print("The job '" .. job .. "' has been removed and is not present in your QBCore jobs. Remove it from the multijob SQL or add it back to your qbcore jobs.lua.")
else
local online = active[job] or 0
getjobs = {
name = job,
grade = grade,
description = Config.Descriptions[job],
icon = Config.FontAwesomeIcons[job],
label = QBCore.Shared.Jobs[job].label,
gradeLabel = QBCore.Shared.Jobs[job].grades[tostring(grade)].name,
salary = QBCore.Shared.Jobs[job].grades[tostring(grade)].payment,
active = online,
}
if Config.WhitelistJobs[job] then
whitelistedjobs[#whitelistedjobs+1] = getjobs
else
civjobs[#civjobs+1] = getjobs
end
end
end

multijobs = {
whitelist = whitelistedjobs,
civilian = civjobs,
}
cb(multijobs)
end
end)

RegisterNetEvent("ps-multijob:changeJob",function(cjob, cgrade)
Expand Down