feat(points): remove points

This commit is contained in:
Linden
2022-04-14 10:58:17 +00:00
parent 7ea609ae91
commit 21e0edd115

View File

@@ -1,32 +1,18 @@
local points = {}
local nearby = {}
function points.new(coords, distance, data)
local id = #points + 1
local self = {
id = id,
coords = coords,
distance = distance
}
for k, v in pairs(data) do
self[k] = v
end
points[id] = self
return self
local function removePoint(self)
points[self.id] = nil
end
local nearby = {}
CreateThread(function()
while true do
local coords = GetEntityCoords(cache.ped)
Wait(300)
table.wipe(nearby)
for i = 1, #points do
local point = points[i]
for _, point in pairs(points) do
local distance = #(coords - point.coords)
if distance <= point.distance then
@@ -58,4 +44,25 @@ CreateThread(function()
end
end)
return points
return {
new = function(coords, distance, data)
local id = #points + 1
local self = {
id = id,
coords = coords,
distance = distance,
remove = removePoint,
}
if data then
for k, v in pairs(data) do
self[k] = v
end
end
points[id] = self
return self
end
}