mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-11-28 13:14:44 +00:00
perf(points): use interval for on-frame thread
This commit is contained in:
1 parent
9a3b17029f
commit
65a5bab623
1 file changed
+11
-7
@@ -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