• KINGS Weekend discounts! VIP and credits cheaper then ever!

QBCORE Trucking logistics simulator (4 Viewers)

  • Post hidden due to user being banned.
  • Post hidden due to user being banned.

Yeshe

Member
Jun 14, 2023
17
1
1
Credits
9
[script:truck_logisti] SCRIPT ERROR: @truck_logistics/server.lua:254: attempt to compare nil with number
[script:truck_logisti] > ref (@truck_logistics/server.lua:254)
[script:truck_logisti] > <unknown> (@oxmysql/dist/build.js:21810)
[script:truck_logisti] > processTicksAndRejections (node:internal/process/task_queues:96)

Line 254: if tonumber(query_users[1].fragile) >= tonumber(query[1].fragile) then

Code:
Code:
RegisterServerEvent("truck_logistics:startContract")
AddEventHandler("truck_logistics:startContract",function(data)
    local id = data.id
    local distance = data.distance
    local reward = data.reward

    local source = source
    if debug_cooldown[source] == nil then
        debug_cooldown[source] = true
        local xPlayer = QBCore.Functions.GetPlayer(source)
        local user_id = xPlayer.PlayerData.citizenid
        if user_id then
            QBCore.Functions.Notify('' .. user_id, 'success', 5000)
            local query = exports['ghmattimysql']:execute("SELECT * FROM `trucker_available_contracts` WHERE contract_id = @id",{['@id'] = id}, function(query)
                if query and query[1] then
                    query_users = exports['ghmattimysql']:execute("SELECT * FROM `trucker_users` WHERE user_id = @user_id", {['@user_id'] = user_id}, function(query_users)
                        if query_users and query_users[1] then
                            if tonumber(query_users[1].product_type) >= tonumber(query[1].cargo_type) then
                                if tonumber(query_users[1].fragile) >= tonumber(query[1].fragile) then
                                    if tonumber(query_users[1].valuable) >= tonumber(query[1].valuable) then
                                        if tonumber(query_users[1].fast) >= tonumber(query[1].fast) then
                                            if Config.habilidade_distancia[tonumber(query_users[1].distance)] >= tonumber(distance) then
                                                if tonumber(query[1].contract_type) == 0 then
                                                    -- Inicia o trabalho
                                                    TriggerClientEvent("truck_logistics:startContract",source,query[1],distance,reward,{})
                                                else
                                                    -- Checa se tem caminhão
                                                    query_truck = exports['ghmattimysql']:execute("SELECT * FROM `trucker_trucks` WHERE driver = 0 AND user_id = @user_id", {['@user_id'] = user_id}, function(query_truck)
                                                        if query_truck and query_truck[1] then
                                                            TriggerClientEvent("truck_logistics:startContract",source,query[1],distance,reward,query_truck[1])
                                                        else
                                                            TriggerClientEvent("QBCore:Notify",source, Lang[Config.lang]['own_truck'], "error")
                                                        end
                                                    end)
                                                end
                                            else
                                                TriggerClientEvent("QBCore:Notify",source, Lang[Config.lang]['no_skill_1'], "error")
                                            end
                                        else
                                            TriggerClientEvent("QBCore:Notify",source,Lang[Config.lang]['no_skill_2'], "error")
                                        end
                                    else
                                        TriggerClientEvent("QBCore:Notify",source,Lang[Config.lang]['no_skill_3'], "error")
                                    end
                                else
                                    TriggerClientEvent("QBCore:Notify",source,Lang[Config.lang]['no_skill_4'], "error")
                                end
                            else
                                TriggerClientEvent("QBCore:Notify",source,Lang[Config.lang]['no_skill_5'], "error")
                            end
                        end
                    end)
                else
                    TriggerClientEvent("QBCore:Notify",source,Lang[Config.lang]['job_already_started'], "error")
                end
            end)
        end
        debug_cooldown[source] = nil
    end
end)

Happens whenever I try to start a job. RIP script
 
Last edited:

Users who are viewing this thread

Top