From 737d3fd1545d703c167414a97f75acb9c7ed8ba0 Mon Sep 17 00:00:00 2001 From: McDiod Date: Sun, 29 Apr 2018 18:24:52 +0200 Subject: [PATCH] fix #9 prevent multiple timout reminders --- functions/endings/fn_presetTimeout.sqf | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/functions/endings/fn_presetTimeout.sqf b/functions/endings/fn_presetTimeout.sqf index 5d0c0f8..e8a704e 100644 --- a/functions/endings/fn_presetTimeout.sqf +++ b/functions/endings/fn_presetTimeout.sqf @@ -11,14 +11,19 @@ _condition = compile _condition; }, [_winName,_condition], _time] call CBA_fnc_waitAndExecute; +if (isNil QGVAR(timeoutReminders)) then {GVAR(timeoutReminders) = []}; { - if (_time > _x) then { - [{ - _timeText = if (_this < 60) then {format ["%1s",_this]} else {format ["%1min",round (_this/60)]}; - _messageText = format ["There are %1 left in the round",_timeText]; - ["grad_notification1",["TIME",_messageText]] remoteExec ["bis_fnc_showNotification",0,false]; - },_x,_time - _x] call CBA_fnc_waitAndExecute; - } else { - ERROR_2("Cannot create a %1 second reminder for timeout. Only %2 seconds max time.",_x,_time); + switch (true) do { + case (_time <= _x): {ERROR_2("Cannot create a %1 second reminder for timeout. Only %2 seconds max time.",_x,_time)}; + case (_x in GVAR(timeoutReminders)): {WARNING_1("Timeout reminder %1s skipped, because one already exists.",_x)}; + default { + [{ + _timeText = if (_this < 60) then {format ["%1s",_this]} else {format ["%1min",round (_this/60)]}; + _messageText = format ["There are %1 left in the round",_timeText]; + ["grad_notification1",["TIME",_messageText]] remoteExec ["bis_fnc_showNotification",0,false]; + },_x,_time - _x] call CBA_fnc_waitAndExecute; + + GVAR(timeoutReminders) pushBack _x; + }; }; } forEach _reminders;