fix(esx_lib/points): start the points loop only once

startLoop is called from the esx:playerLoaded handler in es_extended, which fires
again on every character switch, and the loop it creates runs `while true` with no
exit. Each relog therefore leaves another points thread running: they all scan the
same table, fire the same enter and leave callbacks, and none of them ever stop.

A guard makes a second call a no-op. The loop is meant to live for the resource
lifetime, so starting it twice is never right.

Measured in game on artifact 25770, counting scans over four seconds:
  before: 1.0 -> 2.0 -> 3.0 loops across two relogs
  after:  1.0 -> 1.0 -> 1.0
Points keep working, the surviving loop is unaffected.

Note this touches the same file as #1831, which guards the callbacks inside the
loop. The two changes are in different places and independent of each other.
This commit is contained in:
Selt
2026-07-27 22:50:24 +02:00
parent 5354e278de
commit 443953b24b
+7
View File
@@ -4,6 +4,7 @@ xLib.points = {}
local points = {}
local insidePoints = {}
local handleCount = 0
local loopStarted = false
---@param coords vector3
---@param distance number
@@ -44,6 +45,12 @@ function xLib.points.hide(handle, hidden)
end
function xLib.points.startLoop()
if loopStarted then
return
end
loopStarted = true
CreateThread(function()
local lastScan = 0