Add cleanup of targets when switching players

This commit is contained in:
Jim Shield
2025-08-05 12:40:36 +01:00
parent d6c4619717
commit 76855d3246
3 changed files with 12 additions and 4 deletions

View File

@@ -247,7 +247,7 @@ function GenerateRandomPedData(data)
return newTable
end
onPlayerUnloaded(function()
onPlayerUnload(function()
for k in pairs(Peds) do
DeletePed(Peds[k])
end

View File

@@ -97,7 +97,7 @@ function destroyProp(entity)
end
end
onPlayerUnloaded(function()
onPlayerUnload(function()
for k in pairs(Props) do
DeleteObject(Props[k])
end

View File

@@ -503,8 +503,7 @@ end
-- Cleanup on Resource Stop
-------------------------------------------------------------
-- When the current resource stops, remove all targets.
onResourceStop(function()
local function CleanupTargets()
-- Remove entity targets.
for i = 1, #targetEntities do
if isStarted(OXTargetExport) then
@@ -529,4 +528,13 @@ onResourceStop(function()
exports[QBTargetExport]:RemoveZone(circleTargets[i].name)
end
end
end
onPlayerUnload(function()
CleanupTargets()
end)
-- When the current resource stops, remove all targets.
onResourceStop(function()
CleanupTargets()
end, true)