diff --git a/lib/utility/client/utility.lua b/lib/utility/client/utility.lua index 02ca13b..5363e30 100644 --- a/lib/utility/client/utility.lua +++ b/lib/utility/client/utility.lua @@ -365,16 +365,15 @@ Utility.RemovePoint = function(pointID) end AddEventHandler('onResourceStop', function(resource) - if resource == GetCurrentResourceName() then - for _, blip in pairs(blipIDs) do - if blip and DoesBlipExist(blip) then - RemoveBlip(blip) - end + if resource ~= GetCurrentResourceName() then return end + for _, blip in pairs(blipIDs) do + if blip and DoesBlipExist(blip) then + RemoveBlip(blip) end - for _, ped in pairs(spawnedPeds) do - if ped and DoesEntityExist(ped) then - DeleteEntity(ped) - end + end + for _, ped in pairs(spawnedPeds) do + if ped and DoesEntityExist(ped) then + DeleteEntity(ped) end end end) diff --git a/lib/utility/shared/rebound_entities.lua b/lib/utility/shared/rebound_entities.lua index ff4fc05..2ab3ee7 100644 --- a/lib/utility/shared/rebound_entities.lua +++ b/lib/utility/shared/rebound_entities.lua @@ -162,11 +162,10 @@ RegisterNetEvent("playerJoining", function() end) AddEventHandler('onResourceStart', function(resource) - if resource == GetCurrentResourceName() then - Wait(1000) - for _, src in pairs(GetPlayers()) do - ReboundEntities.Refresh(src) - end + if resource ~= GetCurrentResourceName() then return end + Wait(1000) + for _, src in pairs(GetPlayers()) do + ReboundEntities.Refresh(src) end end) @@ -307,20 +306,18 @@ end) RegisterNetEvent(GetCurrentResourceName() .. ":client:SetReboundSyncData", function(id, key, value) local entityData = ReboundEntities.GetById(id) - if entityData then - entityData[key] = value - if entityData.onSyncKeyChange then - entityData.onSyncKeyChange(entityData, key, value) - end + if not entityData then return end + entityData[key] = value + if entityData.onSyncKeyChange then + entityData.onSyncKeyChange(entityData, key, value) end end) AddEventHandler('onResourceStop', function(resource) - if resource == GetCurrentResourceName() then - spawnLoopRunning = false - for _, entity in pairs(Entities) do - if entity.entity then DeleteEntity(tonumber(entity.entity)) end - end + if resource ~= GetCurrentResourceName() then return end + spawnLoopRunning = false + for _, entity in pairs(Entities) do + if entity.entity then DeleteEntity(tonumber(entity.entity)) end end end)