server.lua Setup

What is the server.lua?

The server.lua is where you can find many of the integrations, primarily money integration. If you want to use money functions ensure that the setting.ini in your script has useMoney=true

Troubleshooting a server.lua file

Many errors spur from not having this set up correctly. If you receive an error that looks something like this:

export_error.png

then you probably don't have your framework configured correctly.

If your error looks something like this:

1679-image.png

then that is likely an error in the server.lua code. We have found a few bugs in the server.lua file that have not quite made it to release yet.

The error lies in a typo of the types, specifically in the qb-core integration and the esx integration.

The qb core integration may look something like this:

if (Player.Functions.GetMoney(bank) <= 75) then

or

if (Player.Functions.GetMoney(bank) >= tonumber(amount)) then

and need to be changed to:

if (Player.Functions.GetMoney('bank') <= 75) then

and

if (Player.Functions.GetMoney('bank') >= tonumber(amount)) then

alternatively if you are using esx it might look something like this:

    elseif framework == 'esx' then
        local xPlayer = ESX.GetPlayerFromId(src)
            if (xPlayer.getAccount("bank") <= 75) then
                TriggerClientEvent('BigDaddy-Fuel:CreditCheckResult', src, false)
            else
                TriggerClientEvent('BigDaddy-Fuel:CreditCheckResult', src, true)
        end

or

    elseif framework == 'esx' then
        local xPlayer = ESX.GetPlayerFromId(src)
        if (xPlayer.getAccount("bank") >= tonumber(amount)) then
            xPlayer.removeAccountMoney('bank', tonumber(amount))
            xPlayer.showNotification(reason)
        end

and will need to be changed to this

    elseif framework == 'esx' then
        local xPlayer = ESX.GetPlayerFromId(src)
        local account = xPlayer.getAccount('bank')
            if (account.money <= 75) then
                TriggerClientEvent('BigDaddy-Fuel:CreditCheckResult', src, false)
            else
                TriggerClientEvent('BigDaddy-Fuel:CreditCheckResult', src, true)
      end

and

    elseif framework == 'esx' then
        local xPlayer = ESX.GetPlayerFromId(src)
        local account = xPlayer.getAccount('bank')
        if (account.money >= tonumber(amount)) then
            xPlayer.removeAccountMoney('bank', tonumber(amount))
            xPlayer.showNotification(reason)
        end

Adding a custom framework/integration

If you have a custom money system that isn't already included in the server.lua then we have made a spot just for you!

On line 1 of the server.lua chnage the framework to custom by setting it to framework = 'custom'

Then in section labeled:

    elseif framework == 'custom' then
        --INSERT CUSTOM CODE HERE FOR CASH MANAGEMENT

place the code required then trigger the same event as all of the other ones.