diff --git a/lib/entities/shared/behaviors/stash.lua b/lib/entities/shared/behaviors/stash.lua index 0c83b66..badbebc 100644 --- a/lib/entities/shared/behaviors/stash.lua +++ b/lib/entities/shared/behaviors/stash.lua @@ -20,24 +20,24 @@ function Stash.OnCreate(entityData) local owner = entityData.stash.owner local groups = entityData.stash.groups Bridge.Inventory.RegisterStash(entityData.id, label, slots, weight, owner, groups) - else - entityData.targets = entityData.targets or {} - entityData.targets['stash'] = { - label = entityData.stash.target.label or Stash.default.target.label, - icon = entityData.stash.target.icon or Stash.default.target.icon, - description = entityData.stash.target.description, - groups = entityData.stash.target.groups, - canInteract = function(_) - local entData = Bridge.Entity.Get(entityData.id) - return not entData.stash.disable - end, - onSelect = function() - TriggerServerEvent("community_bridge:server:OpenStash", entityData.id) - end - } - - Bridge.Entity.Set(entityData.id, 'targets', entityData.targets) - end + return + end + entityData.targets = entityData.targets or {} + entityData.targets['stash'] = { + label = entityData.stash.target.label or Stash.default.target.label, + icon = entityData.stash.target.icon or Stash.default.target.icon, + description = entityData.stash.target.description, + groups = entityData.stash.target.groups, + canInteract = function(_) + local entData = Bridge.Entity.Get(entityData.id) + return not entData.stash.disable + end, + onSelect = function() + TriggerServerEvent("community_bridge:server:OpenStash", entityData.id) + end + } + + Bridge.Entity.Set(entityData.id, 'targets', entityData.targets) end if not IsDuplicityVersion() then return Bridge.Entity.RegisterBehavior("stash", Stash) end diff --git a/lib/entities/shared/behaviors/targets.lua b/lib/entities/shared/behaviors/targets.lua index 99f30d7..c11afc4 100644 --- a/lib/entities/shared/behaviors/targets.lua +++ b/lib/entities/shared/behaviors/targets.lua @@ -61,8 +61,14 @@ function Targets.OnUpdate(entityData) break end end + + for k, v in pairs(entityData.oldTargets) do + if not entityData.targets or not entityData.targets[k] then + doesntMatch = true + break + end + end if doesntMatch then - print("ASDFASDFASDF") Targets.OnRemove(entityData) Wait(100) Targets.OnSpawn(entityData)