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
|
while true do
|
||||||
local coords = GetEntityCoords(PlayerPedId())
|
local coords = GetEntityCoords(PlayerPedId())
|
||||||
|
|
||||||
for _, point in pairs(insidePoints) do
|
for handle, point in pairs(insidePoints) do
|
||||||
point.inside(#(coords - point.coords))
|
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
|
end
|
||||||
|
|
||||||
local now = GetGameTimer()
|
local now = GetGameTimer()
|
||||||
@@ -70,8 +73,8 @@ function xLib.points.startLoop()
|
|||||||
if not point.nearby then
|
if not point.nearby then
|
||||||
point.nearby = true
|
point.nearby = true
|
||||||
|
|
||||||
if point.enter then
|
if point.enter and not pcall(point.enter) then
|
||||||
point.enter()
|
print(("[^1ERROR^7] point ^5%s^7 from ^5%s^7 errored on enter"):format(handle, point.resource))
|
||||||
end
|
end
|
||||||
|
|
||||||
if point.inside then
|
if point.inside then
|
||||||
@@ -81,8 +84,8 @@ function xLib.points.startLoop()
|
|||||||
elseif point.nearby then
|
elseif point.nearby then
|
||||||
point.nearby = false
|
point.nearby = false
|
||||||
|
|
||||||
if point.leave then
|
if point.leave and not pcall(point.leave) then
|
||||||
point.leave()
|
print(("[^1ERROR^7] point ^5%s^7 from ^5%s^7 errored on leave"):format(handle, point.resource))
|
||||||
end
|
end
|
||||||
|
|
||||||
insidePoints[handle] = nil
|
insidePoints[handle] = nil
|
||||||
|
|||||||
Reference in New Issue
Block a user