Skip to content

Commit

Permalink
refactor(client): check if zone was created before calling RemoveZone
Browse files Browse the repository at this point in the history
Minor optimisation but mostly to mitigate ox_target warnings.
  • Loading branch information
thelindat committed Jul 17, 2023
1 parent b9b8259 commit a7baa27
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions modules/inventory/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,15 @@ Inventory.Evidence = setmetatable(data('evidence'), {
for _, evidence in pairs(self) do
if evidence.point then
evidence.point:remove()
end
elseif evidence.zone then
exports.qtarget:RemoveZone(evidence.target.name)
evidence.zone = nil
end

if client.hasGroup(shared.police) then
if shared.target then
if evidence.target then
exports.qtarget:RemoveZone(evidence.target.name)
evidence.zone = true
exports.qtarget:AddBoxZone(evidence.target.name, evidence.target.loc, evidence.target.length or 0.5, evidence.target.width or 0.5,
{
name = evidence.target.name,
Expand Down Expand Up @@ -287,12 +290,15 @@ Inventory.Stashes = setmetatable(data('stashes'), {

if stash.point then
stash.point:remove()
end
elseif stash.zone then
exports.qtarget:RemoveZone(stash.name)
stash.zone = nil
end

if not stash.groups or client.hasGroup(stash.groups) then
if shared.target then
if stash.target then
exports.qtarget:RemoveZone(stash.name)
stash.zone = true
exports.qtarget:AddBoxZone(stash.name, stash.target.loc, stash.target.length or 0.5, stash.target.width or 0.5,
{
name = stash.name,
Expand Down
1 change: 1 addition & 0 deletions modules/shops/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ local function wipeShops()

if shop.zoneId then
pcall(exports.qtarget.RemoveZone, nil, shop.zoneId)
shop.zoneId = nil
end

if shop.remove then
Expand Down

0 comments on commit a7baa27

Please sign in to comment.