From f0822424855da69add30307a78a7ce9b79dc812d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 13 Jan 2015 23:34:55 -0300 Subject: [PATCH] hearing: buggy PFH --- addons/hearing/functions/fnc_earRinging.sqf | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/addons/hearing/functions/fnc_earRinging.sqf b/addons/hearing/functions/fnc_earRinging.sqf index a23fafae99..52e1ac69fc 100644 --- a/addons/hearing/functions/fnc_earRinging.sqf +++ b/addons/hearing/functions/fnc_earRinging.sqf @@ -24,27 +24,24 @@ GVAR(newStrength) = GVAR(newStrength) max _strength; if (missionNamespace getVariable [QGVAR(isEarRingingPlaying), false]) exitWith {}; +_fnc_removeEarRinging = { + GVAR(isEarRingingPlaying) = false; + // Delete this PFH, so it is only executed once + [(_this select 1)] call cba_fnc_removePerFrameHandler; +}; + if (_strength > 0.75) exitWith { playSound "ACE_EarRinging_Heavy"; GVAR(isEarRingingPlaying) = true; - 0 spawn { - sleep 7; - GVAR(isEarRingingPlaying) = false; - }; + [_fnc_removeEarRinging, 7.0, [] ] call CBA_fnc_addPerFrameHandler; }; if (_strength > 0.5) exitWith { playSound "ACE_EarRinging_Medium"; GVAR(isEarRingingPlaying) = true; - 0 spawn { - sleep 5; - GVAR(isEarRingingPlaying) = false; - }; + [_fnc_removeEarRinging, 5.0, [] ] call CBA_fnc_addPerFrameHandler; }; if (_strength > 0.2) exitWith { playSound "ACE_EarRinging_Weak"; GVAR(isEarRingingPlaying) = true; - 0 spawn { - sleep 3; - GVAR(isEarRingingPlaying) = false; - }; + [_fnc_removeEarRinging, 3.0, [] ] call CBA_fnc_addPerFrameHandler; };