Skip to content

Commit 1ca2e45

Browse files
committed
add workaround for if onlineList is nil
1 parent 2e3fef8 commit 1ca2e45

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

client/charge.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@ RegisterNetEvent(getScript()..":client:Charge", function(data, outside)
3333
--Retrieve a list of nearby players from server
3434
local onlineList = triggerCallback(getScript()..":MakePlayerList")
3535
--Convert list of players nearby into one qb-input understands + add distance info
36+
3637
local playerCoords = GetEntityCoords(PlayerPedId())
3738

39+
if onlineList == nil or #onlineList == 0 then
40+
goto failed
41+
end
42+
3843
for _, v in ipairs(GetPlayersFromCoords(playerCoords, Config.General.PaymentRadius)) do
3944
local ped = GetPlayerPed(v)
4045
local dist = #(GetEntityCoords(ped) - playerCoords)
@@ -50,6 +55,7 @@ RegisterNetEvent(getScript()..":client:Charge", function(data, outside)
5055
end
5156
end
5257
end
58+
::failed::
5359

5460
--If list is empty(no one nearby) show error and stop
5561
if not nearbyList[1] then

0 commit comments

Comments
 (0)