mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
perf(points): use interval for on-frame thread
This commit is contained in:
@@ -6,6 +6,7 @@ end
|
|||||||
|
|
||||||
local nearby = {}
|
local nearby = {}
|
||||||
local closest
|
local closest
|
||||||
|
local tick
|
||||||
|
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
while true do
|
while true do
|
||||||
@@ -38,14 +39,17 @@ CreateThread(function()
|
|||||||
point.currentDistance = nil
|
point.currentDistance = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
CreateThread(function()
|
if not tick then
|
||||||
while true do
|
if #nearby > 0 then
|
||||||
Wait(0)
|
tick = SetInterval(function()
|
||||||
for i = 1, #nearby do
|
for i = 1, #nearby do
|
||||||
nearby[i]:nearby()
|
nearby[i]:nearby()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
elseif #nearby == 0 then
|
||||||
|
ClearInterval(tick)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user