Skip to content

Commit

Permalink
Merge pull request #16 from gruppe-adler/prevent-multiple-timeout-rem…
Browse files Browse the repository at this point in the history
…inders

fix #9 prevent multiple timout reminders
  • Loading branch information
McDiod authored Nov 11, 2018
2 parents c743c77 + b40b9ee commit 46b6932
Show file tree
Hide file tree
Showing 2 changed files with 1,519 additions and 2,322 deletions.
21 changes: 13 additions & 8 deletions functions/endings/fn_presetTimeout.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Loading

0 comments on commit 46b6932

Please sign in to comment.