Skip to content

Commit

Permalink
Merge pull request #395 from dijksterhuis/attachments-fixup-double-de…
Browse files Browse the repository at this point in the history
…pleted-notification

Attachments: Fix duplicated notifications.
  • Loading branch information
dijksterhuis authored Sep 6, 2024
2 parents 0843758 + c68cdf4 commit 20fbc29
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Initialises a paradigm scheduled job on the client
checking whether the lightsources have "run out of juice".
or .... every 60 seconds check if 7 minutes has passed and
or .... every 60 seconds check if 10 minutes has passed and
delete all the attached objects and lightsources if so.
Parameter(s): None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ private _ttl = 10 * 60;

private _startTime = player getVariable ["vn_mf_bn_attch_battery_starttime", -1];

// one tick before
((_startTime > 0) && {serverTime > (_startTime + _ttl - 60)}) && {
["LightsourceAttachLosingEnergy",[]] call para_c_fnc_show_notification;
};

// final tick
((_startTime > 0) && {serverTime > (_startTime + _ttl)}) && {
// final tick -- do this before the next one using an exitWith
// to avoid sending duplicate notifications.
if((_startTime > 0) && {serverTime > (_startTime + _ttl)}) exitWith {
diag_log format ["INFO: Light attachment has ran out of battery, removing."];
[player] call vn_mf_fnc_attachments_global_delete_objects;
["LightsourceAttachOutOfEnergy",[]] call para_c_fnc_show_notification;
player setVariable ["vn_mf_bn_attch_battery_starttime", -1];
};
};

// one tick a minute before the player is going to lose the light source.
// assumes we're running this job once a minute!
// see: fn_attachments_client_battery_monitor_init.sqf
if ((_startTime > 0) && {serverTime > (_startTime + _ttl - 60)}) exitWith {
["LightsourceAttachLosingEnergy",[]] call para_c_fnc_show_notification;
};

0 comments on commit 20fbc29

Please sign in to comment.