made woopsie to entities

This commit is contained in:
Mr.Crowley committed 2025-08-05 20:57:26 -05:00
1 parent d0f9fb7ca3
commit 140bad5b34
6 files changed
+130 -49

No files matched your search

+14 -7
View File
@@ -45,19 +45,26 @@ local function SpawnEntity(entityData)
end
end
local function RemoveEntity(entityData, skip)
local function RemoveEntity(entityData)
print(string.format("[ClientEntity] Removing entity %s", entityData.id))
entityData = entityData and entityData.args or entityData
if not entityData then return end
ClientEntityActions.StopAction(entityData.id)
-- ClientEntityActions.StopAction(entityData.id)
print(string.format("[ClientEntity] Stopping actions for entity %s", entityData.id, entityData.OnRemove))
for k, v in pairs(entityData) do
print(string.format("RemoveEntity %s", k))
end
print(json.encode(skip))
if entityData.OnRemove then
print(string.format("[ClientEntity] Calling OnRemove for entity %s", entityData.id))
entityData.OnRemove(entityData)
end
if entityData.spawned and DoesEntityExist(entityData.spawned) then
local entityHandle = entityData.spawned
entityData.spawned = nil
SetEntityAsMissionEntity(entityHandle, false, false)
DeleteEntity(entityHandle)
end
if not skip and entityData.OnRemove then
entityData.OnRemove(entityData)
end
end
end
--- Registers an entity received from the server and sets up proximity spawning.
@@ -239,7 +246,7 @@ AddEventHandler('onResourceStop', function(resourceName)
if resourceName == GetCurrentResourceName() then
for id, entityData in pairs(Entities) do
Point.Remove(id) -- Clean up point registration
RemoveEntity(entityData, true) -- Clean up spawned game entity
RemoveEntity(entityData) -- Clean up spawned game entity
end
Entities = {} -- Clear local cache
end