# Installation

{% tabs %}
{% tab title="QBCore" %}

## qb-core

* Replace the function called `self.Functions.Setjob` with the following

{% code title="qb-core/server/player.lua" %}

```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
```

{% endcode %}

* Set the value `QBShared.ForceJobDefaultDutyAtLogin` to false

{% code title="qb-core\shared\jobs.lua" %}

```lua
QBShared.ForceJobDefaultDutyAtLogin = false
```

{% endcode %}

* Add the following check in the function called `PaycheckInterval`

<pre class="language-lua" data-title="qb-core\server\functions.lua" data-full-width="false"><code class="lang-lua">function PaycheckInterval()
    if next(QBCore.Players) then
        for _, Player in pairs(QBCore.Players) do
            if Player then
                <a data-footnote-ref href="#user-content-fn-1">if QBShared.Jobs[Player.PlayerData.job.name] then</a>
                    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 &#x3C; 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
                <a data-footnote-ref href="#user-content-fn-1">end</a>
            end
        end
    end
    SetTimeout(QBCore.Config.Money.PayCheckTimeOut * (60 * 1000), PaycheckInterval)
end
</code></pre>

* Add the following item

{% code title="qb-core\shared\items.lua" %}

```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"},
```

{% endcode %}

## pma-voice

* Add the following code at the end of the file

{% code title="pma-voice/client/init/main.lua" %}

```lua
exports("toggleVoice", toggleVoice)
exports("playerTargets", playerTargets)
```

{% endcode %}
{% endtab %}

{% tab title="ESX" %}

## es\_extended

* Replace the function called `self.setJob` with the following

{% code title="es\_extended/server/classes/player.lua" %}

```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
```

{% endcode %}

* Comment or remove the following lines of code

{% code title="es\_extended\server\main.lua" %}

```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]
```

{% endcode %}

* Replace the recently commented/removed code with the following

{% code title="es\_extended\server\main.lua" %}

```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
```

{% endcode %}

* Add the following code before the reference line

{% code title="es\_extended\server\paycheck.lua" %}

```lua
if xPlayer.job.isBusiness then
    salary = 0
end

if salary > 0 then -- Reference line
```

{% endcode %}

## pma-voice

* Add the following code at the end of the file

{% code title="pma-voice/client/init/main.lua" %}

```lua
exports("toggleVoice", toggleVoice)
exports("playerTargets", playerTargets)
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="warning" %}
We recommend uploading our script files without using FileZilla, as the upload process may corrupt our scripts. As a recommendation, please use WinSCP or other reliable programs to upload the files.
{% endhint %}

[^1]: Add this check
