mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
feat(points): remove points
This commit is contained in:
@@ -1,32 +1,18 @@
|
|||||||
local points = {}
|
local points = {}
|
||||||
local nearby = {}
|
|
||||||
|
|
||||||
function points.new(coords, distance, data)
|
local function removePoint(self)
|
||||||
local id = #points + 1
|
points[self.id] = nil
|
||||||
|
|
||||||
local self = {
|
|
||||||
id = id,
|
|
||||||
coords = coords,
|
|
||||||
distance = distance
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, v in pairs(data) do
|
|
||||||
self[k] = v
|
|
||||||
end
|
|
||||||
|
|
||||||
points[id] = self
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local nearby = {}
|
||||||
|
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
while true do
|
while true do
|
||||||
local coords = GetEntityCoords(cache.ped)
|
local coords = GetEntityCoords(cache.ped)
|
||||||
Wait(300)
|
Wait(300)
|
||||||
table.wipe(nearby)
|
table.wipe(nearby)
|
||||||
|
|
||||||
for i = 1, #points do
|
for _, point in pairs(points) do
|
||||||
local point = points[i]
|
|
||||||
local distance = #(coords - point.coords)
|
local distance = #(coords - point.coords)
|
||||||
|
|
||||||
if distance <= point.distance then
|
if distance <= point.distance then
|
||||||
@@ -58,4 +44,25 @@ CreateThread(function()
|
|||||||
end
|
end
|
||||||
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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user