From 99b146d7b9a234a7e37e2743f5ca39d10248b682 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Sun, 11 Sep 2022 11:02:04 +1000 Subject: [PATCH] fix(client/zones): zone triggers twice when inside and debug is enabled Zones would be added to the temporary array twice, so callback functions and the zone draw would trigger twice. --- imports/zones/client.lua | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/imports/zones/client.lua b/imports/zones/client.lua index 1c4a288..88803d9 100644 --- a/imports/zones/client.lua +++ b/imports/zones/client.lua @@ -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 @@ -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