From 55b45062250ec351be1f3f58ebea4a46160b69b9 Mon Sep 17 00:00:00 2001 From: Bxio Date: Mon, 3 Aug 2026 11:38:57 +0000 Subject: [PATCH] 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. --- client.lua | 9 +++++++-- fxmanifest.lua | 2 +- version.json | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/client.lua b/client.lua index a0eb85d..9d675a1 100644 --- a/client.lua +++ b/client.lua @@ -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) diff --git a/fxmanifest.lua b/fxmanifest.lua index 31b1d54..e0f5e6b 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -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 { diff --git a/version.json b/version.json index afa49c8..a4c7e1e 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "1.1.2" + "version": "1.1.3" }