🔧Installation
Follow these steps to ensure the script works correctly
qb-core
Replace the function called
self.Functions.Setjob
with the following
qb-core/server/player.lua
function self.Functions.SetJob(job, grade, fromMJ)
local job = job:lower()
local grade = tostring(grade) or '0'
if QBCore.Shared.Jobs[job] ~= nil then
if not fromMJ and GetResourceState('origen_masterjob') == 'started' then
local BusN = exports["origen_masterjob"]:GetBusiness(self.PlayerData.job.name)
if BusN then
BusN.Functions.RemovePlayer(self.PlayerData.citizenid, true)
TriggerClientEvent("origen_masterjob:client:OnBusinessUpdate", self.PlayerData.source, false)
end
end
self.PlayerData.job.name = job
self.PlayerData.job.label = QBCore.Shared.Jobs[job].label
self.PlayerData.job.onduty = QBCore.Shared.Jobs[job].defaultDuty
if QBCore.Shared.Jobs[job].grades[grade] then
local jobgrade = QBCore.Shared.Jobs[job].grades[grade]
self.PlayerData.job.grade = {}
self.PlayerData.job.grade.name = jobgrade.name
self.PlayerData.job.grade.level = tonumber(grade)
self.PlayerData.job.payment = jobgrade.payment ~= nil and jobgrade.payment or 30
self.PlayerData.job.isboss = jobgrade.isboss ~= nil and jobgrade.isboss or false
else
return false
end
self.Functions.UpdatePlayerData()
TriggerClientEvent("QBCore:Client:OnJobUpdate", self.PlayerData.source, self.PlayerData.job)
return true
elseif GetResourceState('origen_masterjob') == 'started' then
local BusN = exports["origen_masterjob"]:GetBusiness(job)
if BusN then
local jobgrade = BusN.Functions.GetGrade(grade)
if not jobgrade then
return false
end
local oldBusN = exports["origen_masterjob"]:GetBusiness(self.PlayerData.job.name)
if oldBusN then
BusN.Functions.RemovePlayer(self.PlayerData.citizenid, true)
TriggerClientEvent("origen_masterjob:client:OnBusinessUpdate", self.PlayerData.source, false)
end
self.PlayerData.job.name = job
self.PlayerData.job.label = BusN.Data.label
self.PlayerData.job.onduty = false
self.PlayerData.job.grade = {}
self.PlayerData.job.grade.name = jobgrade.label or "Sin grado"
self.PlayerData.job.grade.level = tonumber(grade)
self.PlayerData.job.payment = jobgrade.pay or 30
self.PlayerData.job.isboss = jobgrade.boss or false
self.Functions.UpdatePlayerData()
TriggerClientEvent("QBCore:Client:OnJobUpdate", self.PlayerData.source, self.PlayerData.job)
if not fromMJ then
BusN.Functions.AddPlayer(self.PlayerData.citizenid, self.PlayerData.charinfo.firstname .. " " .. self.PlayerData.charinfo.lastname, tostring(grade), true)
end
return true
end
end
return false
end
Set the value
QBShared.ForceJobDefaultDutyAtLogin
to false
qb-core\shared\jobs.lua
QBShared.ForceJobDefaultDutyAtLogin = false
Add the following check in the function called
PaycheckInterval
qb-core\server\functions.lua
function PaycheckInterval()
if next(QBCore.Players) then
for _, Player in pairs(QBCore.Players) do
if Player then
local payment = QBShared.Jobs[Player.PlayerData.job.name]['grades'][tostring(Player.PlayerData.job.grade.level)].payment
if not payment then payment = Player.PlayerData.job.payment end
if Player.PlayerData.job and payment > 0 and (QBShared.Jobs[Player.PlayerData.job.name].offDutyPay or Player.PlayerData.job.onduty) then
if QBCore.Config.Money.PayCheckSociety then
local account = exports['qb-management']:GetAccount(Player.PlayerData.job.name)
if account ~= 0 then
if account < payment then
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('error.company_too_poor'), 'error')
else
Player.Functions.AddMoney('bank', payment, 'paycheck')
exports['qb-management']:RemoveMoney(Player.PlayerData.job.name, payment)
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
end
else
Player.Functions.AddMoney('bank', payment, 'paycheck')
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
end
else
Player.Functions.AddMoney('bank', payment, 'paycheck')
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
end
end
end
end
end
SetTimeout(QBCore.Config.Money.PayCheckTimeOut * (60 * 1000), PaycheckInterval)
end
Add the following item
qb-core\shared\items.lua
['business_cad'] = {["name"] = "business_cad", ["label"] = "Business tablet", ["weight"] = 0, ["type"] = "item", ["image"] = "tablet.png", ["unique"] = true, ["useable"] = true, ["shouldClose"] = false, ["combinable"] = nil, ["description"] = "Your personal tablet with all the information of the San Andreas business"},
pma-voice
Add the following code at the end of the file
pma-voice/client/init/main.lua
exports("toggleVoice", toggleVoice)
exports("playerTargets", playerTargets)
es_extended
Replace the function called
self.setJob
with the following
es_extended/server/classes/player.lua
function self.setJob(newJob, grade)
grade = tostring(grade)
local lastJob = json.decode(json.encode(self.job))
if ESX.DoesJobExist(newJob, grade) then
if not fromMJ and GetResourceState('origen_masterjob'):find('start') then
local BusN = exports["origen_masterjob"]:GetBusiness(self.job.name)
if BusN then
BusN.Functions.RemovePlayer(self.identifier, true)
TriggerClientEvent("origen_masterjob:client:OnBusinessUpdate", self.source, false)
end
end
local jobObject, gradeObject = ESX.Jobs[newJob], ESX.Jobs[newJob].grades[grade]
self.job.id = jobObject.id
self.job.name = jobObject.name
self.job.label = jobObject.label
self.job.grade = tonumber(grade)
self.job.grade_name = gradeObject.name
self.job.grade_label = gradeObject.label
self.job.grade_salary = gradeObject.salary
if gradeObject.skin_male then
self.job.skin_male = json.decode(gradeObject.skin_male)
else
self.job.skin_male = {}
end
if gradeObject.skin_female then
self.job.skin_female = json.decode(gradeObject.skin_female)
else
self.job.skin_female = {}
end
TriggerEvent('esx:setJob', self.source, self.job, lastJob)
self.triggerEvent('esx:setJob', self.job, lastJob)
Player(self.source).state:set("job", self.job, true)
elseif GetResourceState('origen_masterjob'):find('start') then
local BusN = exports["origen_masterjob"]:GetBusiness(newJob)
if BusN then
local jobgrade = BusN.Functions.GetGrade(grade)
if not jobgrade then
print(('[es_extended] [^3WARNING^7] Ignoring invalid ^5.setJob()^7 usage for ID: ^5%s^7, Job: ^5%s^7'):format(self.source, newJob))
end
local oldBusN = exports["origen_masterjob"]:GetBusiness(self.job.name)
if oldBusN then
oldBusN.Functions.RemovePlayer(self.identifier, true)
TriggerClientEvent("origen_masterjob:client:OnBusinessUpdate", self.source, false)
end
self.job.name = newJob
self.job.label = BusN.Data.label
self.job.grade = tonumber(grade)
self.job.grade_name = jobgrade.boss and "boss" or jobgrade.label:lower():gsub(" ", "_")
self.job.grade_label = jobgrade.label or "Sin grado"
self.job.grade_salary = jobgrade.pay or 30
self.job.isBusiness = true
self.job.skin_male = {}
self.job.skin_female = {}
TriggerEvent('esx:setJob', self.source, self.job, lastJob)
self.triggerEvent('esx:setJob', self.job, lastJob)
Player(self.source).state:set("job", self.job, true)
if not fromMJ then
BusN.Functions.AddPlayer(self.identifier, self.get("firstName") .. " " .. self.get("lastName"), tostring(grade), true)
end
else
print(('[es_extended] [^3WARNING^7] Ignoring invalid ^5.setJob()^7 usage for ID: ^5%s^7, Job: ^5%s^7'):format(self.source, newJob))
end
else
print(('[es_extended] [^3WARNING^7] Ignoring invalid ^5.setJob()^7 usage for ID: ^5%s^7, Job: ^5%s^7'):format(self.source, newJob))
end
end
Comment or remove the following lines of code
es_extended\server\main.lua
if not ESX.DoesJobExist(job, grade) then
print(("[^3WARNING^7] Ignoring invalid job for ^5%s^7 [job: ^5%s^7, grade: ^5%s^7]"):format(identifier, job, grade))
job, grade = "unemployed", "0"
end
local jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade]
Replace the recently commented/removed code with the following
es_extended\server\main.lua
if ESX.DoesJobExist(job, grade) then
jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade]
elseif GetResourceState('origen_masterjob'):find('start') then
local BusN = exports["origen_masterjob"]:GetBusiness(job)
if BusN then
local jobgrade = BusN.Functions.GetGrade(grade)
if jobgrade then
jobObject = {
id = BusN.Data.id,
name = job,
label = BusN.Data.label,
}
gradeObject = {
name = jobgrade.boss and "boss" or jobgrade.label:lower():gsub(" ", "_"),
label = jobgrade.label or "Sin grado",
salary = jobgrade.pay or 30
}
else
print(('[^3WARNING^7] Ignoring invalid job for ^5%s^7 [job: ^5%s^7, grade: ^5%s^7]'):format(identifier, job, grade))
end
else
print(('[^3WARNING^7] Ignoring invalid job for ^5%s^7 [job: ^5%s^7, grade: ^5%s^7]'):format(identifier, job, grade))
end
else
print(('[^3WARNING^7] Ignoring invalid job for ^5%s^7 [job: ^5%s^7, grade: ^5%s^7]'):format(identifier, job, grade))
job, grade = 'unemployed', '0'
jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade]
end
Add the following code before the reference line
es_extended\server\paycheck.lua
if xPlayer.job.isBusiness then
salary = 0
end
if salary > 0 then -- Reference line
pma-voice
Add the following code at the end of the file
pma-voice/client/init/main.lua
exports("toggleVoice", toggleVoice)
exports("playerTargets", playerTargets)
Last updated