Skip to content
This repository was archived by the owner on Apr 29, 2025. It is now read-only.

Commit ff2e765

Browse files
committed
fix(points): store all points within range in nearbyZones
Previously this only stored points with the nearby method.
1 parent d0db63e commit ff2e765

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

imports/points/client.lua

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,14 @@ end
3333

3434
CreateThread(function()
3535
while true do
36-
if nearbyCount ~= 0 then
37-
table.wipe(nearbyPoints)
38-
nearbyCount = 0
39-
end
40-
4136
local coords = GetEntityCoords(cache.ped)
4237
local newPoints = lib.grid.getNearbyEntries(coords, function(entry) return entry.remove == removePoint end) --[[@as CPoint[] ]]
4338
local cellX, cellY = lib.grid.getCellPosition(coords)
4439
cache.coords = coords
4540
closestPoint = nil
4641

4742
if cellX ~= cache.lastCellX or cellY ~= cache.lastCellY then
48-
for i = 1, #nearbyPoints do
43+
for i = 1, nearbyCount do
4944
local point = nearbyPoints[i]
5045

5146
if point.inside then
@@ -64,6 +59,11 @@ CreateThread(function()
6459
cache.lastCellY = cellY
6560
end
6661

62+
if nearbyCount ~= 0 then
63+
table.wipe(nearbyPoints)
64+
nearbyCount = 0
65+
end
66+
6767
for i = 1, #newPoints do
6868
local point = newPoints[i]
6969
local distance = #(coords - point.coords)
@@ -78,10 +78,8 @@ CreateThread(function()
7878
closestPoint = point
7979
end
8080

81-
if point.nearby then
82-
nearbyCount += 1
83-
nearbyPoints[nearbyCount] = point
84-
end
81+
nearbyCount += 1
82+
nearbyPoints[nearbyCount] = point
8583

8684
if point.onEnter and not point.inside then
8785
point.inside = true

0 commit comments

Comments
 (0)