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:
parent
cc53d101cb
commit
55b4506225
@ -283,6 +283,13 @@ end)
|
|||||||
|
|
||||||
AddEventHandler('onClientResourceStart', function(resourceName)
|
AddEventHandler('onClientResourceStart', function(resourceName)
|
||||||
if resourceName ~= GetCurrentResourceName() then return end
|
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
|
for id, ent in pairs(spawnedSafes) do
|
||||||
if ent and DoesEntityExist(ent) then
|
if ent and DoesEntityExist(ent) then
|
||||||
@ -291,6 +298,4 @@ AddEventHandler('onClientResourceStart', function(resourceName)
|
|||||||
end
|
end
|
||||||
spawnedSafes[id] = nil
|
spawnedSafes[id] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
TriggerServerEvent('safe:requestSync')
|
|
||||||
end)
|
end)
|
||||||
|
|||||||
@ -4,7 +4,7 @@ lua54 'yes'
|
|||||||
|
|
||||||
author 'SeuNome'
|
author 'SeuNome'
|
||||||
description 'Sistema de safes com ox_inventory e ox_target'
|
description 'Sistema de safes com ox_inventory e ox_target'
|
||||||
version '1.1.2'
|
version '1.1.3'
|
||||||
|
|
||||||
-- Dependências
|
-- Dependências
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"version": "1.1.2"
|
"version": "1.1.3"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user