mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
feat(points): get closest point
This commit is contained in:
@@ -5,11 +5,13 @@ local function removePoint(self)
|
||||
end
|
||||
|
||||
local nearby = {}
|
||||
local closest
|
||||
|
||||
CreateThread(function()
|
||||
while true do
|
||||
local coords = GetEntityCoords(cache.ped)
|
||||
Wait(300)
|
||||
closest = nil
|
||||
table.wipe(nearby)
|
||||
|
||||
for _, point in pairs(points) do
|
||||
@@ -18,6 +20,10 @@ CreateThread(function()
|
||||
if distance <= point.distance then
|
||||
point.currentDistance = distance
|
||||
|
||||
if distance < (closest?.currentDistance or point.distance) then
|
||||
closest = point
|
||||
end
|
||||
|
||||
if point.nearby then
|
||||
nearby[#nearby + 1] = point
|
||||
end
|
||||
@@ -64,5 +70,9 @@ return {
|
||||
points[id] = self
|
||||
|
||||
return self
|
||||
end,
|
||||
|
||||
closest = function()
|
||||
return closest
|
||||
end
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user