Clean up spawned safe props on resource stop, bump to 1.1.3

The cleanup loop ran on onClientResourceStart, but spawnedSafes is
already a fresh empty table by then, so it never actually deleted
anything. Props from before a restart stayed orphaned in the world
and got duplicated by the requestSync on start. Moved the cleanup to
onClientResourceStop, which runs while the entities are still known.
This commit is contained in:
Bxio 2026-08-03 11:38:57 +00:00
parent cc53d101cb
commit 55b4506225
3 changed files with 9 additions and 4 deletions

View File

@ -283,6 +283,13 @@ end)
AddEventHandler('onClientResourceStart', function(resourceName)
if resourceName ~= GetCurrentResourceName() then return end
TriggerServerEvent('safe:requestSync')
end)
-- Roda ANTES do ambiente do script ser destruído, diferente de onClientResourceStart
-- (nesse ponto spawnedSafes já estaria vazio, pois o script já teria reiniciado)
AddEventHandler('onClientResourceStop', function(resourceName)
if resourceName ~= GetCurrentResourceName() then return end
for id, ent in pairs(spawnedSafes) do
if ent and DoesEntityExist(ent) then
@ -291,6 +298,4 @@ AddEventHandler('onClientResourceStart', function(resourceName)
end
spawnedSafes[id] = nil
end
TriggerServerEvent('safe:requestSync')
end)

View File

@ -4,7 +4,7 @@ lua54 'yes'
author 'SeuNome'
description 'Sistema de safes com ox_inventory e ox_target'
version '1.1.2'
version '1.1.3'
-- Dependências
dependencies {

View File

@ -1,3 +1,3 @@
{
"version": "1.1.2"
"version": "1.1.3"
}