Skip to content

Commit

Permalink
fix(client/zones): zone triggers twice when inside and debug is enabled
Browse files Browse the repository at this point in the history
Zones would be added to the temporary array twice, so callback functions
and the zone draw would trigger twice.
  • Loading branch information
thelindat committed Sep 11, 2022
1 parent 5d4eff8 commit 99b146d
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions imports/zones/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -232,30 +232,32 @@ CreateThread(function()
zone.distance = #(zone.coords - coords)

if contains then
if zone.onEnter and not zone.insideZone then
zone:onEnter()
if not zone.insideZone then
zone.insideZone = true

if zone.onEnter then
zone:onEnter()
end
end

if zone.inside then
insideCount += 1
inside[insideCount] = zone
end
else
if zone.insideZone then
zone.insideZone = false

if not zone.insideZone then
zone.insideZone = true
if zone.onExit then
zone:onExit()
end
end
elseif zone.insideZone then
zone.insideZone = false

if zone.onExit then
zone:onExit()
if zone.debug then
insideCount += 1
inside[insideCount] = zone
end
end

if zone.debug then
insideCount += 1
inside[insideCount] = zone
end
end

if not tick then
Expand All @@ -266,10 +268,12 @@ CreateThread(function()


if zone.debug then
if zone.insideZone then zone:inside() end

zone:debug()
elseif zone.insideZone then

if zone.inside and zone.insideZone then
zone:inside()
end
else
zone:inside()
end
end
Expand Down

0 comments on commit 99b146d

Please sign in to comment.