fix(client/modules/points): safely iterate over sparse points table

This commit is contained in:
Ilias Rbayti
2024-11-09 09:34:49 +01:00
parent 26d229d36b
commit 483fee8602
+6 -7
View File
@@ -28,8 +28,7 @@ function StartPointsLoop()
CreateThread(function()
while true do
local coords = GetEntityCoords(ESX.PlayerData.ped)
for i=1, #points do
local point = points[i]
for i, point in pairs(points) do
local distance = #(coords - point.coords)
if not point.hidden and distance <= point.distance then
@@ -50,9 +49,9 @@ end
AddEventHandler('onResourceStop', function(resource)
for i=1, #points do
if points[i].resource == resource then
points[i] = nil
end
end
for i, point in pairs(points) do
if point.resource == resource then
points[i] = nil
end
end
end)