Fix for data being nil

This commit is contained in:
jimathy
2022-02-25 10:10:08 +00:00
committed by GitHub
parent 07c0195d26
commit e3e8d71bea

View File

@@ -38,7 +38,7 @@ Citizen.CreateThread(function()
{ options = { { event = "jim-payments:Tickets:Menu", icon = "fas fa-receipt", label = "Cash in Receipts", job = jobroles } }, distance = 2.0 }) { options = { { event = "jim-payments:Tickets:Menu", icon = "fas fa-receipt", label = "Cash in Receipts", job = jobroles } }, distance = 2.0 })
end) end)
RegisterNetEvent('jim-payments:client:Charge', function() RegisterNetEvent('jim-payments:client:Charge', function(data)
if not onDuty then TriggerEvent("QBCore:Notify", "Not Clocked in!", "error") return end -- Require to be on duty when making a payment if not onDuty then TriggerEvent("QBCore:Notify", "Not Clocked in!", "error") return end -- Require to be on duty when making a payment
local onlineList = {} local onlineList = {}
local nearbyList = {} local nearbyList = {}
@@ -48,14 +48,13 @@ RegisterNetEvent('jim-payments:client:Charge', function()
for i = 1, #onlineList do for i = 1, #onlineList do
if onlineList[i].value == GetPlayerServerId(v) then if onlineList[i].value == GetPlayerServerId(v) then
if v ~= PlayerId() then if v ~= PlayerId() then
nearbyList[#nearbyList+1] = onlineList[i] nearbyList[#nearbyList+1] = { value = onlineList[i].value, text = onlineList[i].text..' ('..math.floor(dist+0.05)..'m)' }
nearbyList[#nearbyList].text = nearbyList[#nearbyList].text..' ('..math.floor(dist+0.05)..'m)'
end end
end end
end end
dist = nil dist = nil
end end
if data.img ~= nil then img = data.img else img = "" end if data.img == nil then img = "" else img = data.img end
if nearbyList[#nearbyList] == nil then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end if nearbyList[#nearbyList] == nil then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
local dialog = exports['qb-input']:ShowInput({ header = img..PlayerJob.label.." Cash Register", submitText = "Send", local dialog = exports['qb-input']:ShowInput({ header = img..PlayerJob.label.." Cash Register", submitText = "Send",
inputs = { inputs = {