QB GUIDE

I show you what you have to modify in QB so that everything works with QB scripts.

It's possible that we might have forgotten a script or that new scripts will be released, or you might even need to add the export to a non-default QB script.

Don't worry, all you need to do is look for the qb-banking exports related to society and replace them with one of ours.

PAYCHECK: In the QB-Core configuration you can activate that the salaries come out of the companies. To make this work with Neon Boss Menu do this:

Step 1: Locate the Paycheck Function

  1. Open your server files and navigate to the qb-core resource.

  2. Go to the server directory.

  3. Open the functions.lua file. You might find this file at a path similar to qb-core/server/functions.lua.

Step 2: Find the PaycheckInterval Function

  1. Search for the PaycheckInterval function within the functions.lua file. This might be around line 309 or further down, depending on your version.

  2. You should see a function definition similar to this:

    function PaycheckInterval()
        -- existing code
    end

Step 3: Modify the PaycheckInterval Function

Replace the existing PaycheckInterval function with the following code to integrate the neon-boss exports:

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 societyData = exports['neon-boss']:GetSocietyData(Player.PlayerData.job.name)
                        local accountBalance = societyData.balance
                        if accountBalance ~= 0 then          -- Checks if player is employed by a society
                            if accountBalance < payment then -- Checks if company has enough money to pay society
                                TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('error.company_too_poor'), 'error')
                            else
                                Player.Functions.AddMoney('bank', payment, 'paycheck')
                                exports['neon-boss']:RemoveSocietyMoney(Player.PlayerData.job.name, Player.PlayerData.charinfo.firstname, payment, 'Employee 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
                    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

Step 4: Save and Test

  1. Save the modified functions.lua file.

  2. Restart your FiveM server to apply the changes.

  3. Test the paycheck functionality in-game to ensure everything works correctly and players receive their paychecks from the society's funds as expected.

Explanation

  • societyData: Fetches society data using the neon-boss export.

  • accountBalance: Checks the balance of the society.

  • RemoveSocietyMoney: Deducts the payment from the society's account.

  • AddMoney: Adds the paycheck amount to the player's bank account.

  • Notifications: Notifies the player if the society is too poor to pay or confirms the payment.

By following these steps, you'll successfully integrate the neon-boss exports into your paycheck function, ensuring seamless payment processing for your players.

QB-PHONE: Make the bills you make with the phone compatible with NEON BOSS MENU and show up in the UI:

Step 1: Locate the Billing Function

  1. Open your server files and navigate to the qb-phone resource.

  2. Go to the server directory.

  3. Open the main.lua file.

Step 2: Find the Callback for Paying Invoices

  1. Search for the QBCore.Functions.CreateCallback('qb-phone:server:PayInvoice', ...) function.

Step 3: Modify the PayInvoice Callback

Replace the existing PayInvoice callback function with the following code:

QBCore.Functions.CreateCallback('qb-phone:server:PayInvoice', function(source, cb, society, amount, invoiceId, sendercitizenid)
    local Invoices = {}
    local Ply = QBCore.Functions.GetPlayer(source)
    local SenderPly = QBCore.Functions.GetPlayerByCitizenId(sendercitizenid)
    local invoiceMailData = {}

    if SenderPly and Config.BillingCommissions[society] then
        local commission = round(amount * Config.BillingCommissions[society])
        SenderPly.Functions.AddMoney('bank', commission)
        invoiceMailData = {
            sender = 'Billing Department',
            subject = 'Commission Received',
            message = string.format('You received a commission check of $%s when %s %s paid a bill of $%s.', commission, Ply.PlayerData.charinfo.firstname, Ply.PlayerData.charinfo.lastname, amount)
        }
    elseif not SenderPly and Config.BillingCommissions[society] then
        invoiceMailData = {
            sender = 'Billing Department',
            subject = 'Bill Paid',
            message = string.format('%s %s paid a bill of $%s', Ply.PlayerData.charinfo.firstname, Ply.PlayerData.charinfo.lastname, amount)
        }
    end

    Ply.Functions.RemoveMoney('bank', amount, 'paid-invoice')
    exports['qb-phone']:sendNewMailToOffline(sendercitizenid, invoiceMailData)
    exports['neon-boss']:AddSocietyMoney(society, Ply.PlayerData.charinfo.firstname, amount, 'Phone invoice')
    
    MySQL.query('DELETE FROM phone_invoices WHERE id = ?', { invoiceId })
    local invoices = MySQL.query.await('SELECT * FROM phone_invoices WHERE citizenid = ?', { Ply.PlayerData.citizenid })
    
    if invoices[1] ~= nil then
        Invoices = invoices
    end
    
    cb(true, Invoices)
end)
QB-AMBULANCEJOB: Have the money paid into the ambulance company and all invoices are integrated:

Step 1: Locate the Event Handlers

  1. Open your server files and navigate to the qb-ambulancejob resource.

  2. Go to the server directory.

  3. Open the main.lua file.

Step 2: Find and Modify hospital:server:SendToBed

  1. Search for the event RegisterNetEvent('hospital:server:SendToBed', ...).

  2. Replace the existing function with:

RegisterNetEvent('hospital:server:SendToBed', function(bedId, isRevive, hospitalIndex)
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
    TriggerClientEvent('hospital:client:SendToBed', src, bedId, Config.Locations['hospital'][hospitalIndex]['beds'][bedId], isRevive)
    TriggerClientEvent('hospital:client:SetBed', -1, bedId, true, hospitalIndex)
    Player.Functions.RemoveMoney('bank', Config.BillCost, 'respawned-at-hospital')
    exports['neon-boss']:AddSocietyMoney('ambulance', Player.PlayerData.charinfo.firstname, Config.BillCost, 'Player treatment')
    TriggerClientEvent('hospital:client:SendBillEmail', src, Config.BillCost, Config.Locations['hospital'][hospitalIndex]['name'])
end)

Step 3: Find and Modify hospital:server:RespawnAtHospital

  1. Search for the event RegisterNetEvent('hospital:server:RespawnAtHospital', ...).

  2. Replace the existing function with:

RegisterNetEvent('hospital:server:RespawnAtHospital', function(hospitalIndex)
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
    if Player.PlayerData.metadata['injail'] > 0 then
        for k, v in pairs(Config.Locations['jailbeds']) do
            if not v.taken then
                TriggerClientEvent('hospital:client:SendToBed', src, k, v, true)
                TriggerClientEvent('hospital:client:SetBed2', -1, k, true)
                if Config.WipeInventoryOnRespawn then
                    Player.Functions.ClearInventory()
                    MySQL.Async.execute('UPDATE players SET inventory = ? WHERE citizenid = ?', { json.encode({}), Player.PlayerData.citizenid })
                    TriggerClientEvent('QBCore:Notify', src, Lang:t('error.possessions_taken'), 'error')
                end
                Player.Functions.RemoveMoney('bank', Config.BillCost, 'respawned-at-hospital')
                exports['neon-boss']:AddSocietyMoney('ambulance', Player.PlayerData.charinfo.firstname, Config.BillCost, 'Player treatment')
                TriggerClientEvent('hospital:client:SendBillEmail', src, Config.BillCost)
                return
            end
        end

        TriggerClientEvent('hospital:client:SendToBed', src, 1, Config.Locations['jailbeds'][1], true)
        TriggerClientEvent('hospital:client:SetBed', -1, 1, true)
        if Config.WipeInventoryOnRespawn then
            Player.Functions.ClearInventory()
            MySQL.Async.execute('UPDATE players SET inventory = ? WHERE citizenid = ?', { json.encode({}), Player.PlayerData.citizenid })
            TriggerClientEvent('QBCore:Notify', src, Lang:t('error.possessions_taken'), 'error')
        end
        Player.Functions.RemoveMoney('bank', Config.BillCost, 'respawned-at-hospital')
        exports['neon-boss']:AddSocietyMoney('ambulance', Player.PlayerData.charinfo.firstname, Config.BillCost, 'Player treatment')
        TriggerClientEvent('hospital:client:SendBillEmail', src, Config.BillCost)
    else
        for k, v in pairs(Config.Locations['hospital'][hospitalIndex]['beds']) do
            if not v.taken then
                TriggerClientEvent('hospital:client:SendToBed', src, k, v, true)
                TriggerClientEvent('hospital:client:SetBed', -1, k, true, hospitalIndex)
                if Config.WipeInventoryOnRespawn then
                    Player.Functions.ClearInventory()
                    MySQL.update('UPDATE players SET inventory = ? WHERE citizenid = ?', { json.encode({}), Player.PlayerData.citizenid })
                    TriggerClientEvent('QBCore:Notify', src, Lang:t('error.possessions_taken'), 'error')
                end
                Player.Functions.RemoveMoney('bank', Config.BillCost, 'respawned-at-hospital')
                exports['neon-boss']:AddSocietyMoney('ambulance', Player.PlayerData.charinfo.firstname, Config.BillCost, 'Player treatment')
                TriggerClientEvent('hospital:client:SendBillEmail', src, Config.BillCost, Config.Locations['hospital'][hospitalIndex]['name'])
                return
            end
        end

        -- All beds were full, placing in first bed as fallback
        TriggerClientEvent('hospital:client:SendToBed', src, 1, Config.Locations['hospital'][hospitalIndex]['beds'][1], true)
        TriggerClientEvent('hospital:client:SetBed', -1, 1, true, hospitalIndex)
        if Config.WipeInventoryOnRespawn then
            Player.Functions.ClearInventory()
            MySQL.update('UPDATE players SET inventory = ? WHERE citizenid = ?', { json.encode({}), Player.PlayerData.citizenid })
            TriggerClientEvent('QBCore:Notify', src, Lang:t('error.possessions_taken'), 'error')
        end
        Player.Functions.RemoveMoney('bank', Config.BillCost, 'respawned-at-hospital')
        exports['neon-boss']:AddSocietyMoney('ambulance', Player.PlayerData.charinfo.firstname, Config.BillCost, 'Player treatment')
        TriggerClientEvent('hospital:client:SendBillEmail', src, Config.BillCost, Config.Locations['hospital'][hospitalIndex]['name'])
    end
end)

Step 4: Save and Test

  1. Save the modified main.lua file.

  2. Restart your FiveM server.

  3. Test the hospital functions in-game to ensure they work correctly with the neon-boss exports.

By following these steps, you'll update the hospital billing functions to use the neon-boss exports for managing society funds.

QB-POLICEJOB: Have the money paid into the police society and also have the fine invoices integrated:

Step 1: Locate the Command Handler for Fines

  1. Open your server files and navigate to the qb-policejob resource.

  2. Go to the server directory.

  3. Open the main.lua file.

  4. Find the QBCore.Commands.Add('fine', ...) function.

Step 2: Modify the QBCore.Commands.Add('fine', ...) Function

Replace the existing function with:

QBCore.Commands.Add('fine', Lang:t('commands.fine'), { { name = 'id', help = Lang:t('info.player_id') }, { name = 'amount', help = Lang:t('info.amount') } }, false, function(source, args)
    local biller = QBCore.Functions.GetPlayer(source)
    local billed = QBCore.Functions.GetPlayer(tonumber(args[1]))
    local amount = tonumber(args[2])
    if biller.PlayerData.job.type == 'leo' then
        if billed ~= nil then
            if biller.PlayerData.citizenid ~= billed.PlayerData.citizenid then
                if amount and amount > 0 then
                    if billed.Functions.RemoveMoney('bank', amount, 'paid-fine') then
                        TriggerClientEvent('QBCore:Notify', source, Lang:t('info.fine_issued'), 'success')
                        TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, Lang:t('info.received_fine'))
                        exports['neon-boss']:AddSocietyMoney(biller.PlayerData.job.name, biller.PlayerData.charinfo.firstname, amount, 'Fine')
                    elseif billed.Functions.RemoveMoney('cash', amount, 'paid-fine') then
                        TriggerClientEvent('QBCore:Notify', source, Lang:t('info.fine_issued'), 'success')
                        TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, Lang:t('info.received_fine'))
                        exports['neon-boss']:AddSocietyMoney(biller.PlayerData.job.name, biller.PlayerData.charinfo.firstname, amount, 'Fine')
                    else
                        MySQL.Async.insert('INSERT INTO phone_invoices (citizenid, amount, society, sender, sendercitizenid) VALUES (?, ?, ?, ?, ?)', { billed.PlayerData.citizenid, amount, biller.PlayerData.job.name, biller.PlayerData.charinfo.firstname, biller.PlayerData.citizenid }, function(id)
                            if id then
                                TriggerClientEvent('qb-phone:client:AcceptorDenyInvoice', billed.PlayerData.source, id, biller.PlayerData.charinfo.firstname, biller.PlayerData.job.name, biller.PlayerData.citizenid, amount, GetInvokingResource())
                            end
                        end)
                        TriggerClientEvent('qb-phone:RefreshPhone', billed.PlayerData.source)
                    end
                else
                    TriggerClientEvent('QBCore:Notify', source, Lang:t('error.amount_higher'), 'error')
                end
            else
                TriggerClientEvent('QBCore:Notify', source, Lang:t('error.fine_yourself'), 'error')
            end
        else
            TriggerClientEvent('QBCore:Notify', source, Lang:t('error.not_online'), 'error')
        end
    else
        TriggerClientEvent('QBCore:Notify', source, Lang:t('error.on_duty_police_only'), 'error')
    end
end)

Step 3: Locate the Event Handler for Billing Players

  1. Find the RegisterNetEvent('police:server:BillPlayer', ...) function in the same file.

Step 4: Modify the RegisterNetEvent('police:server:BillPlayer', ...) Function

Replace the existing function with:

RegisterNetEvent('police:server:BillPlayer', function(playerId, price)
    local src = source
    local playerPed = GetPlayerPed(src)
    local targetPed = GetPlayerPed(playerId)
    local playerCoords = GetEntityCoords(playerPed)
    local targetCoords = GetEntityCoords(targetPed)
    if #(playerCoords - targetCoords) > 2.5 then return DropPlayer(src, 'Attempted exploit abuse') end

    local Player = QBCore.Functions.GetPlayer(src)
    local OtherPlayer = QBCore.Functions.GetPlayer(playerId)
    if not Player or not OtherPlayer or Player.PlayerData.job.type ~= 'leo' then return end

    OtherPlayer.Functions.RemoveMoney('bank', price, 'paid-bills')
    exports['neon-boss']:AddSocietyMoney('police', Player.PlayerData.charinfo.firstname, price, 'Fine paid')
    TriggerClientEvent('QBCore:Notify', OtherPlayer.PlayerData.source, Lang:t('info.fine_received', { fine = price }))
end)

Step 5: Save and Test

  1. Save the modified main.lua file.

  2. Restart your FiveM server.

  3. Test the functionality in-game to ensure it works correctly with the neon-boss exports.

By following these steps, you'll update the police job billing functions to use the neon-boss exports for managing society funds.

QB-TAXIJOB: Have the money paid into the cab company and also have the taxi invoices integrated:

Step 1: Locate the Event Handler for NPC Payments

  1. Open your server files and navigate to the qb-taxijob resource.

  2. Go to the server directory.

  3. Open the main.lua file.

  4. Find the RegisterNetEvent('qb-taxi:server:NpcPay', ...) function.

Step 2: Modify the RegisterNetEvent('qb-taxi:server:NpcPay', ...) Function

Replace the existing function with:

RegisterNetEvent('qb-taxi:server:NpcPay', function(Payment)
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
    if Player.PlayerData.job.name == Config.jobRequired then
        if NearTaxi(src) then
            local randomAmount = math.random(1, 5)
            local r1, r2 = math.random(1, 5), math.random(1, 5)
            if randomAmount == r1 or randomAmount == r2 then Payment = Payment + math.random(10, 20) end
            if Config.Management then
                exports['neon-boss']:AddSocietyMoney('taxi', Player.PlayerData.charinfo.firstname, Payment, 'Customer payment')
            else
                Player.Functions.AddMoney('cash', Payment, 'taxi payout')
            end
            local chance = math.random(1, 100)
            if chance < 26 then
                Player.Functions.AddItem('cryptostick', 1, false)
                TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items['cryptostick'], 'add')
            end
        else
            DropPlayer(src, 'Attempting To Exploit')
        end
    else
        DropPlayer(src, 'Attempting To Exploit')
    end
end)

Step 3: Save and Test

  1. Save the modified main.lua file.

  2. Restart your FiveM server.

  3. Test the NPC payment functionality in-game to ensure it works correctly with the neon-boss exports.

Summary

  • Locate: Open qb-taxijob/server/main.lua.

  • Modify: Replace the RegisterNetEvent('qb-taxi:server:NpcPay', ...) function with the provided code.

  • Save and Test: Save the file, restart your server, and test the changes.

By following these steps, you'll update the taxi job payment functions to use the neon-boss exports for managing society funds.

Last updated