mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
fix(points): store all points within range in nearbyZones
Previously this only stored points with the nearby method.
This commit is contained in:
@@ -33,11 +33,6 @@ end
|
|||||||
|
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
while true do
|
while true do
|
||||||
if nearbyCount ~= 0 then
|
|
||||||
table.wipe(nearbyPoints)
|
|
||||||
nearbyCount = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
local coords = GetEntityCoords(cache.ped)
|
local coords = GetEntityCoords(cache.ped)
|
||||||
local newPoints = lib.grid.getNearbyEntries(coords, function(entry) return entry.remove == removePoint end) --[[@as CPoint[] ]]
|
local newPoints = lib.grid.getNearbyEntries(coords, function(entry) return entry.remove == removePoint end) --[[@as CPoint[] ]]
|
||||||
local cellX, cellY = lib.grid.getCellPosition(coords)
|
local cellX, cellY = lib.grid.getCellPosition(coords)
|
||||||
@@ -45,7 +40,7 @@ CreateThread(function()
|
|||||||
closestPoint = nil
|
closestPoint = nil
|
||||||
|
|
||||||
if cellX ~= cache.lastCellX or cellY ~= cache.lastCellY then
|
if cellX ~= cache.lastCellX or cellY ~= cache.lastCellY then
|
||||||
for i = 1, #nearbyPoints do
|
for i = 1, nearbyCount do
|
||||||
local point = nearbyPoints[i]
|
local point = nearbyPoints[i]
|
||||||
|
|
||||||
if point.inside then
|
if point.inside then
|
||||||
@@ -64,6 +59,11 @@ CreateThread(function()
|
|||||||
cache.lastCellY = cellY
|
cache.lastCellY = cellY
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if nearbyCount ~= 0 then
|
||||||
|
table.wipe(nearbyPoints)
|
||||||
|
nearbyCount = 0
|
||||||
|
end
|
||||||
|
|
||||||
for i = 1, #newPoints do
|
for i = 1, #newPoints do
|
||||||
local point = newPoints[i]
|
local point = newPoints[i]
|
||||||
local distance = #(coords - point.coords)
|
local distance = #(coords - point.coords)
|
||||||
@@ -78,10 +78,8 @@ CreateThread(function()
|
|||||||
closestPoint = point
|
closestPoint = point
|
||||||
end
|
end
|
||||||
|
|
||||||
if point.nearby then
|
nearbyCount += 1
|
||||||
nearbyCount += 1
|
nearbyPoints[nearbyCount] = point
|
||||||
nearbyPoints[nearbyCount] = point
|
|
||||||
end
|
|
||||||
|
|
||||||
if point.onEnter and not point.inside then
|
if point.onEnter and not point.inside then
|
||||||
point.inside = true
|
point.inside = true
|
||||||
|
|||||||
Reference in New Issue
Block a user