🔧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)

Last updated