add global broadcast on players waiting longer than threshold, log
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
|
||||||
|
// if a player files for reinsert using self-interaction
|
||||||
|
// they're added to the queue along with their nearest base location and the time they filed
|
||||||
|
// if a player's time in the queue exceeds the configured timeout, a message will be posted every 5 minutes on a cycle based around
|
||||||
|
// the player's time in the queue stating how long they have been waiting, their name, and their group's name
|
||||||
|
|
||||||
// execute for all
|
// execute for all
|
||||||
if (isNil "milsim_respawn_setting_reinsertion_maxRangeToReady") then {
|
if (isNil "milsim_respawn_setting_reinsertion_maxRangeToReady") then {
|
||||||
// configured in CBA settings
|
// configured in CBA settings
|
||||||
@@ -12,34 +18,49 @@ if (isServer) then {
|
|||||||
milsim_respawn_reinsertionQueue = [];
|
milsim_respawn_reinsertionQueue = [];
|
||||||
publicVariable "milsim_respawn_reinsertionQueue";
|
publicVariable "milsim_respawn_reinsertionQueue";
|
||||||
|
|
||||||
|
milsim_respawn_reinsertionOverTimeoutLastNotificationTime = 0;
|
||||||
|
|
||||||
// register event handlers
|
// register event handlers
|
||||||
["milsim_respawn_fileReinsertRequest", {
|
["milsim_respawn_fileReinsertRequest", {
|
||||||
params ["_unit", "_closestBaseName"];
|
params ["_unit", "_closestBaseName", "_time"];
|
||||||
milsim_respawn_reinsertionQueue pushBackUnique [_unit, _closestBaseName];
|
milsim_respawn_reinsertionQueue pushBackUnique [_unit, _closestBaseName, _time];
|
||||||
diag_log text format [
|
diag_log text format [
|
||||||
"[milsim] (respawn_reinsertion) ADDED name=%1 playerUID=%2 closestBase=%3",
|
"[milsim] (respawn_reinsertion) ADDED name=%1 playerUID=%2 filedAtBase=%3",
|
||||||
name _unit, getPlayerUID _unit, _closestBaseName
|
name _unit,
|
||||||
|
getPlayerUID _unit,
|
||||||
|
_closestBaseName
|
||||||
];
|
];
|
||||||
publicVariable "milsim_respawn_reinsertionQueue";
|
publicVariable "milsim_respawn_reinsertionQueue";
|
||||||
}] call CBA_fnc_addEventHandler;
|
}] call CBA_fnc_addEventHandler;
|
||||||
["milsim_respawn_removeReinsertRequest", {
|
["milsim_respawn_removeReinsertRequest", {
|
||||||
params ["_unit"];
|
params ["_unit"];
|
||||||
if (count (milsim_respawn_reinsertionQueue select {_x#0 isEqualTo _unit}) isEqualTo 0) exitWith {};
|
private _unitArrs = milsim_respawn_reinsertionQueue select {_x#0 isEqualTo _unit};
|
||||||
milsim_respawn_reinsertionQueue = milsim_respawn_reinsertionQueue select {_x#0 isNotEqualTo _unit};
|
if (count _unitArrs isEqualTo 0) exitWith {};
|
||||||
diag_log text format ["[milsim] (respawn_reinsertion) REMOVED BY REQUEST name=%1 playerUID=%2",
|
|
||||||
name _unit, getPlayerUID _unit
|
milsim_respawn_reinsertionQueue = milsim_respawn_reinsertionQueue - _unitArrs;
|
||||||
|
// sort _unitArrs by time in queue, descending
|
||||||
|
[_unitArrs, [], {
|
||||||
|
_x#2
|
||||||
|
}, "DESCEND"] call BIS_fnc_sortBy;
|
||||||
|
(_unitArrs#0) params ["_unit", "_baseName", "_timeFiled"]; // _unitArr = [unit, baseName, timeInQueue]
|
||||||
|
private _timeInQueue = diag_tickTime - (_timeFiled);
|
||||||
|
diag_log text format ["[milsim] (respawn_reinsertion) REMOVED BY REQUEST name=%1 playerUID=%2 filedAtBase=%3 inQueue=%4s",
|
||||||
|
name _unit,
|
||||||
|
getPlayerUID _unit,
|
||||||
|
_baseName,
|
||||||
|
_timeInQueue
|
||||||
];
|
];
|
||||||
publicVariable "milsim_respawn_reinsertionQueue";
|
publicVariable "milsim_respawn_reinsertionQueue";
|
||||||
}] call CBA_fnc_addEventHandler;
|
}] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[{
|
||||||
// every 60 seconds, revalidate any players in the queue
|
// every 60 seconds, revalidate any players in the queue
|
||||||
// compare their distance to the nearest base, and remove them if they're too far away (or dead)
|
// compare their distance to the nearest base, and remove them if they're too far away (or dead)
|
||||||
[{
|
|
||||||
private _stillValid = [];
|
private _stillValid = [];
|
||||||
{
|
{
|
||||||
private _queueData = _x;
|
_x params ["_player", "_baseName", "_timeFiled"]; // _unitArr = [unit, baseName, timeInQueue]
|
||||||
private _player = _queueData#0;
|
|
||||||
private _nearBase = false;
|
private _nearBase = false;
|
||||||
private _nearestDistance = 99999;
|
private _nearestDistance = 99999;
|
||||||
{
|
{
|
||||||
@@ -57,14 +78,62 @@ if (isServer) then {
|
|||||||
_stillValid pushBackUnique _queueData;
|
_stillValid pushBackUnique _queueData;
|
||||||
} else {
|
} else {
|
||||||
diag_log text format [
|
diag_log text format [
|
||||||
"[milsim] (respawn_reinsertion) REMOVED AUTOMATICALLY name=%1 playerUID=%2 nearestBase=%3m",
|
"[milsim] (respawn_reinsertion) REMOVED AUTOMATICALLY name=%1 playerUID=%2 filedAtBase=%3 nearestBaseDistance=%4m inQueue=%5s",
|
||||||
name _player, getPlayerUID _player, _nearestDistance
|
name _unit,
|
||||||
|
getPlayerUID _unit,
|
||||||
|
_baseName,
|
||||||
|
_nearestDistance,
|
||||||
|
diag_tickTime - _timeFiled
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
} forEach milsim_respawn_reinsertionQueue;
|
} forEach milsim_respawn_reinsertionQueue;
|
||||||
|
|
||||||
|
// broadcast new list to all machines
|
||||||
milsim_respawn_reinsertionQueue = _stillValid;
|
milsim_respawn_reinsertionQueue = _stillValid;
|
||||||
publicVariable "milsim_respawn_reinsertionQueue";
|
publicVariable "milsim_respawn_reinsertionQueue";
|
||||||
|
|
||||||
|
|
||||||
|
// if at least 1 player in the queue has been waiting longer than the configured timeout,
|
||||||
|
// show a notification to all players if the last notification was more than 5 minutes ago
|
||||||
|
private _needNotification =
|
||||||
|
diag_tickTime - milsim_respawn_reinsertionOverTimeoutLastNotificationTime > 60*5 // if last notification was more than 5 minutes ago
|
||||||
|
if (_needNotification) then {
|
||||||
|
private _timeout = missionNamespace getVariable ["milsim_respawn_setting_reinsertion_timeout", 60*20]; // default 20 minutes
|
||||||
|
private _timeoutPlayers = milsim_respawn_reinsertionQueue select {alive (_x#0) && (diag_tickTime - (_x#2)) > _timeout};
|
||||||
|
if (count _timeoutPlayers > 0) then {
|
||||||
|
// sort _timeoutPlayers by time in queue, descending
|
||||||
|
_timeoutPlayers = [_timeoutPlayers, [], {
|
||||||
|
_x#2
|
||||||
|
}, "DESCEND"] call BIS_fnc_sortBy;
|
||||||
|
private _playerLines = _timeoutPlayers apply {
|
||||||
|
private _timeInQueue = diag_tickTime - (_x#2);
|
||||||
|
private _groupId = groupID (_x#0);
|
||||||
|
[format [
|
||||||
|
"%1: %2 [%2s]",
|
||||||
|
_groupId,
|
||||||
|
name (_x#0),
|
||||||
|
[_timeInQueue, "MM:SS"] call BIS_fnc_secondsToString
|
||||||
|
], 0.8, [0.8, 0.8, 0.8, 1]];
|
||||||
|
};
|
||||||
|
["Players are still waiting for Re-insert!", _playerLines] remoteExec ["CBA_fnc_notify", -2];
|
||||||
|
|
||||||
|
milsim_respawn_reinsertionOverTimeoutLastNotificationTime = diag_tickTime;
|
||||||
|
|
||||||
|
diag_log text format [
|
||||||
|
"[milsim] (respawn_reinsertion) PLAYERS WAITING LONGER THAN %1s: %2",
|
||||||
|
_timeout,
|
||||||
|
_timeoutPlayers apply {
|
||||||
|
format[
|
||||||
|
"%1: %2 [%3]",
|
||||||
|
groupID (_x#0),
|
||||||
|
name _x#0,
|
||||||
|
diag_tickTime - (_x#2)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
}, 60] call CBA_fnc_addPerFrameHandler;
|
}, 60] call CBA_fnc_addPerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -92,7 +161,7 @@ if (hasInterface) then {
|
|||||||
params ["_target", "_player", "_params"];
|
params ["_target", "_player", "_params"];
|
||||||
private _closestBase = [milsim_respawn_bases, _player] call BIS_fnc_nearestPosition;
|
private _closestBase = [milsim_respawn_bases, _player] call BIS_fnc_nearestPosition;
|
||||||
private _closestBaseName = _closestBase getVariable ["name", "unknown"];
|
private _closestBaseName = _closestBase getVariable ["name", "unknown"];
|
||||||
["milsim_respawn_fileReinsertRequest", [_player, _closestBaseName]] call CBA_fnc_serverEvent;
|
["milsim_respawn_fileReinsertRequest", [_player, _closestBaseName, diag_tickTime]] call CBA_fnc_serverEvent;
|
||||||
[["Re-insert Request Filed"], [format["Pickup at %1", _closestBaseName]]] call CBA_fnc_notify;
|
[["Re-insert Request Filed"], [format["Pickup at %1", _closestBaseName]]] call CBA_fnc_notify;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -162,6 +162,15 @@
|
|||||||
true
|
true
|
||||||
] call CBA_fnc_addSetting;
|
] call CBA_fnc_addSetting;
|
||||||
|
|
||||||
|
[
|
||||||
|
"milsim_respawn_setting_reinsertion_timeout", // variable
|
||||||
|
"SLIDER", // type
|
||||||
|
["Request Timeout", "How long should at least one person be waiting before prompting a global notification."], // title
|
||||||
|
["17th Battalion", "Re-insert Queue"], // category
|
||||||
|
[60*10, 60*30, 60*20, 0, false], // [_min, _max, _default, _trailingDecimals, _isPercentage
|
||||||
|
true
|
||||||
|
] call CBA_fnc_addSetting;
|
||||||
|
|
||||||
diag_log text "[MILSIM] (settings) Custom CBA settings initialized";
|
diag_log text "[MILSIM] (settings) Custom CBA settings initialized";
|
||||||
|
|
||||||
nil;
|
nil;
|
||||||
Reference in New Issue
Block a user