mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-28 17:01:14 +00:00
Merge pull request #1831 from seltonmt012/fix/points-loop-guard
fix(esx_lib/points): keep the points loop alive when a callback errors
This commit is contained in:
@@ -57,8 +57,11 @@ function xLib.points.startLoop()
|
||||
while true do
|
||||
local coords = GetEntityCoords(PlayerPedId())
|
||||
|
||||
for _, point in pairs(insidePoints) do
|
||||
point.inside(#(coords - point.coords))
|
||||
for handle, point in pairs(insidePoints) do
|
||||
if not pcall(point.inside, #(coords - point.coords)) then
|
||||
insidePoints[handle] = nil
|
||||
print(("[^1ERROR^7] point ^5%s^7 from ^5%s^7 errored on inside"):format(handle, point.resource))
|
||||
end
|
||||
end
|
||||
|
||||
local now = GetGameTimer()
|
||||
@@ -70,8 +73,8 @@ function xLib.points.startLoop()
|
||||
if not point.nearby then
|
||||
point.nearby = true
|
||||
|
||||
if point.enter then
|
||||
point.enter()
|
||||
if point.enter and not pcall(point.enter) then
|
||||
print(("[^1ERROR^7] point ^5%s^7 from ^5%s^7 errored on enter"):format(handle, point.resource))
|
||||
end
|
||||
|
||||
if point.inside then
|
||||
@@ -81,8 +84,8 @@ function xLib.points.startLoop()
|
||||
elseif point.nearby then
|
||||
point.nearby = false
|
||||
|
||||
if point.leave then
|
||||
point.leave()
|
||||
if point.leave and not pcall(point.leave) then
|
||||
print(("[^1ERROR^7] point ^5%s^7 from ^5%s^7 errored on leave"):format(handle, point.resource))
|
||||
end
|
||||
|
||||
insidePoints[handle] = nil
|
||||
|
||||
Reference in New Issue
Block a user