From ff2e765b60e039c30ec11b3b8a8cba911d4b25cf Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Tue, 18 Mar 2025 05:36:57 +1100 Subject: [PATCH] fix(points): store all points within range in nearbyZones Previously this only stored points with the nearby method. --- imports/points/client.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/imports/points/client.lua b/imports/points/client.lua index c8608d4..e763523 100644 --- a/imports/points/client.lua +++ b/imports/points/client.lua @@ -33,11 +33,6 @@ end CreateThread(function() while true do - if nearbyCount ~= 0 then - table.wipe(nearbyPoints) - nearbyCount = 0 - end - local coords = GetEntityCoords(cache.ped) local newPoints = lib.grid.getNearbyEntries(coords, function(entry) return entry.remove == removePoint end) --[[@as CPoint[] ]] local cellX, cellY = lib.grid.getCellPosition(coords) @@ -45,7 +40,7 @@ CreateThread(function() closestPoint = nil if cellX ~= cache.lastCellX or cellY ~= cache.lastCellY then - for i = 1, #nearbyPoints do + for i = 1, nearbyCount do local point = nearbyPoints[i] if point.inside then @@ -64,6 +59,11 @@ CreateThread(function() cache.lastCellY = cellY end + if nearbyCount ~= 0 then + table.wipe(nearbyPoints) + nearbyCount = 0 + end + for i = 1, #newPoints do local point = newPoints[i] local distance = #(coords - point.coords) @@ -78,10 +78,8 @@ CreateThread(function() closestPoint = point end - if point.nearby then - nearbyCount += 1 - nearbyPoints[nearbyCount] = point - end + nearbyCount += 1 + nearbyPoints[nearbyCount] = point if point.onEnter and not point.inside then point.inside = true