From e6d00c83d20b1a959d3a3b19c2aeed98ffafa214 Mon Sep 17 00:00:00 2001 From: Tony <97451137+TonybynMp4@users.noreply.github.com> Date: Tue, 7 Nov 2023 09:42:26 +0100 Subject: [PATCH] fix the oxygen loop --- client/main.lua | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/client/main.lua b/client/main.lua index de0b72f..7e4708c 100644 --- a/client/main.lua +++ b/client/main.lua @@ -348,16 +348,18 @@ RegisterNetEvent('qb-diving:client:UseGear', function() currentGear.enabled = true TriggerServerEvent("InteractSound_SV:PlayOnSource", "breathdivingsuit", 0.25) CreateThread(function() - while currentGear.enabled and IsPedSwimmingUnderWater(cache.ped) do - oxygenLevel -= 1 - if oxygenLevel % 10 == 0 and oxygenLevel ~= 100 then - TriggerServerEvent("InteractSound_SV:PlayOnSource", "breathdivingsuit", 0.25) - elseif oxygenLevel == 0 then - SetEnableScuba(cache.ped, false) - SetPedMaxTimeUnderwater(cache.ped, 1.00) - currentGear.enabled = false - isWearingSuit = false - TriggerServerEvent("InteractSound_SV:PlayOnSource", nil, 0.25) + while currentGear.enabled do + if IsPedSwimmingUnderWater(cache.ped) then + oxygenLevel -= 1 + if oxygenLevel % 10 == 0 and oxygenLevel ~= 100 then + TriggerServerEvent("InteractSound_SV:PlayOnSource", "breathdivingsuit", 0.25) + elseif oxygenLevel == 0 then + SetEnableScuba(cache.ped, false) + SetPedMaxTimeUnderwater(cache.ped, 1.00) + currentGear.enabled = false + isWearingSuit = false + TriggerServerEvent("InteractSound_SV:PlayOnSource", nil, 0.25) + end end Wait(1000) end