reinsert-requests #14
@@ -81,5 +81,6 @@ class milsim_respawn {
|
||||
file = "functions\respawn";
|
||||
class init { postInit = 1; };
|
||||
class showReinsertQueueNotification {};
|
||||
class getNearestBase {};
|
||||
};
|
||||
};
|
||||
15
functions/respawn/fn_getNearestBase.sqf
Normal file
15
functions/respawn/fn_getNearestBase.sqf
Normal file
@@ -0,0 +1,15 @@
|
||||
params [["_player", objNull, [objNull]]];
|
||||
if (isNull _player) exitWith {[99999, ""]};
|
||||
|
||||
private _bases = missionNamespace getVariable ["milsim_respawn_bases", []];
|
||||
if (count _bases == 0) exitWith {[99999, ""]};
|
||||
|
||||
// get nearest base (Module_Respawn_F)
|
||||
private _closestBase = [_bases, _player] call BIS_fnc_nearestPosition;
|
||||
// get distance
|
||||
private _nearestDistance = _closestBase distance _player;
|
||||
// get base name
|
||||
private _baseName = _closestBase getVariable ["name", ""];
|
||||
if (_baseName == "") then {_baseName = format["near %1", text (nearestLocation [_closestBase, ""])]};
|
||||
|
||||
[_nearestDistance, _baseName];
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
// 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
|
||||
// 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
|
||||
@@ -22,14 +22,14 @@ if (isServer) then {
|
||||
|
||||
// register event handlers
|
||||
["milsim_respawn_fileReinsertRequest", {
|
||||
params ["_unit", "_closestBaseName", "_time"];
|
||||
milsim_respawn_reinsertionQueue pushBackUnique [_unit, _closestBaseName, _time];
|
||||
params ["_unit", "_closestBaseName"];
|
||||
milsim_respawn_reinsertionQueue pushBackUnique [
|
||||
_unit, _closestBaseName, diag_tickTime
|
||||
];
|
||||
diag_log text format [
|
||||
"[milsim] (respawn_reinsertion) ADDED name=%1 playerUID=%2 group=%3 filedAtBase=%4",
|
||||
name _unit,
|
||||
getPlayerUID _unit,
|
||||
groupId (group _unit),
|
||||
_closestBaseName
|
||||
"[milsim] (respawn_reinsertion) PLAYER FILED REQUEST :: filedAtBase=""%1"" %2",
|
||||
_closestBaseName,
|
||||
[_unit] call milsim_fnc_getPlayerLogString
|
||||
];
|
||||
publicVariable "milsim_respawn_reinsertionQueue";
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
@@ -45,12 +45,10 @@ if (isServer) then {
|
||||
}, "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 group=%3 filedAtBase=%4 inQueue=%5s",
|
||||
name _unit,
|
||||
getPlayerUID _unit,
|
||||
groupId (group _unit),
|
||||
diag_log text format ["[milsim] (respawn_reinsertion) PLAYER RESCINDED REQUEST :: filedAtBase=""%1"" inQueueDuration=""%2s"" %3",
|
||||
_baseName,
|
||||
_timeInQueue
|
||||
_timeInQueue,
|
||||
[_unit] call milsim_fnc_getPlayerLogString
|
||||
];
|
||||
publicVariable "milsim_respawn_reinsertionQueue";
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
@@ -61,30 +59,23 @@ if (isServer) then {
|
||||
// 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)
|
||||
private _stillValid = [];
|
||||
private _maxRangeToReady = missionNamespace getVariable ["milsim_respawn_setting_reinsertion_maxRangeToReady", 400];
|
||||
{
|
||||
_x params ["_player", "_baseName", "_timeFiled"]; // _unitArr = [unit, baseName, timeInQueue]
|
||||
private _nearestDistance = 99999;
|
||||
{
|
||||
private _baseLocation = _x;
|
||||
private _distanceFromBase = _player distance _baseLocation;
|
||||
if (_distanceFromBase < _nearestDistance) then {
|
||||
_nearestDistance = _distanceFromBase;
|
||||
};
|
||||
} forEach milsim_respawn_bases;
|
||||
|
||||
|
||||
private _nearBase = _nearestDistance < milsim_respawn_setting_reinsertion_maxRangeToReady;
|
||||
private _nearBase = _nearestDistance < _maxRangeToReady;
|
||||
|
||||
if (_nearBase && alive _player) then {
|
||||
_stillValid pushBackUnique _x;
|
||||
} else {
|
||||
diag_log text format [
|
||||
"[milsim] (respawn_reinsertion) REMOVED AUTOMATICALLY name=%1 playerUID=%2 group=%3 filedAtBase=%4 nearestBaseDistance=%5m inQueue=%6s",
|
||||
name _player,
|
||||
getPlayerUID _player,
|
||||
groupId (group _player),
|
||||
"[milsim] (respawn_reinsertion) PLAYER DEQUEUED AUTOMATICALLY :: filedAtBase=""%1"" nearestBaseDistance=""%2m"" maxDistanceSetting=""%3m"" inQueueDuration=""%4s"" %5",
|
||||
_baseName,
|
||||
_nearestDistance,
|
||||
diag_tickTime - _timeFiled
|
||||
_maxRangeToReady,
|
||||
diag_tickTime - _timeFiled,
|
||||
[_player] call milsim_fnc_getPlayerLogString
|
||||
];
|
||||
};
|
||||
} forEach milsim_respawn_reinsertionQueue;
|
||||
@@ -96,12 +87,12 @@ if (isServer) then {
|
||||
|
||||
// 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 =
|
||||
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) &&
|
||||
alive (_x#0) &&
|
||||
(diag_tickTime - (_x#2)) > _timeout
|
||||
};
|
||||
if (count _timeoutPlayers > 0) then {
|
||||
@@ -109,34 +100,31 @@ if (isServer) then {
|
||||
_timeoutPlayers = [_timeoutPlayers, [], {
|
||||
_x#2
|
||||
}, "DESCEND"] call BIS_fnc_sortBy;
|
||||
|
||||
// GLOBAL CBA NOTIFY
|
||||
private _playerLines = [["Players are still waiting for Re-insert!"]];
|
||||
{
|
||||
private _timeInQueue = diag_tickTime - (_x#2);
|
||||
private _groupId = groupID (group (_x#0));
|
||||
_playerLines pushBack ([format [
|
||||
"%1: %2 [%3]",
|
||||
_groupId,
|
||||
groupID (group (_x#0)),
|
||||
name (_x#0),
|
||||
[_timeInQueue, "MM:SS"] call BIS_fnc_secondsToString
|
||||
[diag_tickTime - (_x#2), "MM:SS"] call BIS_fnc_secondsToString
|
||||
], 0.8, [0.8, 0.8, 0.8, 1]]);
|
||||
} forEach _timeoutPlayers;
|
||||
_playerLines remoteExec ["CBA_fnc_notify", [0, -2] select isDedicated];
|
||||
|
||||
// RESET NOTIFICATION TIMER
|
||||
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 (group (_x#0)),
|
||||
name (_x#0),
|
||||
diag_tickTime - (_x#2)
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
// LOG TO RPT
|
||||
{
|
||||
diag_log text format [
|
||||
"[milsim] (respawn_reinsertion) PLAYER WAITING OVER TIMEOUT :: timeout=""%1s"" inQueueDuration=""%2s"" %3",
|
||||
_timeout,
|
||||
diag_tickTime - (_x#2),
|
||||
[_x#0] call milsim_fnc_getPlayerLogString
|
||||
];
|
||||
} forEach _timeoutPlayers;
|
||||
};
|
||||
};
|
||||
}, 60] call CBA_fnc_addPerFrameHandler;
|
||||
@@ -157,26 +145,36 @@ if (hasInterface) then {
|
||||
(localNamespace getVariable ["milsim_respawn_fileForReinsertClassesAdded", []])
|
||||
find _type != -1
|
||||
) exitWith {};
|
||||
|
||||
|
||||
private _fileForReinsertAction = [
|
||||
"milsim_respawn_fileReinsertRequest",
|
||||
"File Re-insert Request",
|
||||
"\A3\ui_f\data\igui\cfg\simpleTasks\types\takeoff_ca.paa",
|
||||
{
|
||||
params ["_target", "_player", "_params"];
|
||||
private _closestBase = [milsim_respawn_bases, _player] call BIS_fnc_nearestPosition;
|
||||
private _closestBaseName = _closestBase getVariable ["name", ""];
|
||||
if (_closestBaseName == "") then {_closestBaseName = format["near %1", text (nearestLocation [_closestBase, ""])]};
|
||||
["milsim_respawn_fileReinsertRequest", [_player, _closestBaseName, diag_tickTime]] call CBA_fnc_serverEvent;
|
||||
[["Re-insert Request Filed"], [format["Pickup at %1", _closestBaseName]]] call CBA_fnc_notify;
|
||||
// find nearest base or location
|
||||
([_player] call milsim_respawn_fnc_getNearestBase) params [
|
||||
"_baseDistance", "_baseName"
|
||||
];
|
||||
// send event to server
|
||||
["milsim_respawn_fileReinsertRequest", [_player, _baseName]] call CBA_fnc_serverEvent;
|
||||
// notify player their request was filed
|
||||
[["Re-insert Request Filed"], [format["Location: %1", _baseName]]] call CBA_fnc_notify;
|
||||
},
|
||||
{
|
||||
params ["_target", "_player", "_params"];
|
||||
private _closestBase = [milsim_respawn_bases, _player] call BIS_fnc_nearestPosition;
|
||||
// find nearest base or location
|
||||
([_player] call milsim_respawn_fnc_getNearestBase) params [
|
||||
"_baseDistance", "_baseName"
|
||||
];
|
||||
|
||||
private _maxRangeToReady = missionNamespace getVariable ["milsim_respawn_setting_reinsertion_maxRangeToReady", 400];
|
||||
private _existingQueue = missionNamespace getVariable ["milsim_respawn_reinsertionQueue", []];
|
||||
|
||||
// check if module is enabled, player is near a base, and player is not already in the queue
|
||||
missionNamespace getVariable ["milsim_respawn_setting_reinsertion_enabled", true] &&
|
||||
(_player distance _closestBase < milsim_respawn_setting_reinsertion_maxRangeToReady) &&
|
||||
not (_player in ((missionNamespace getVariable ["milsim_respawn_reinsertionQueue", []]) apply {_x#0}))
|
||||
(_baseDistance < _maxRangeToReady) &&
|
||||
not (_player in (_existingQueue apply {_x#0}))
|
||||
}
|
||||
] call ace_interact_menu_fnc_createAction;
|
||||
[_type, 1, ["ACE_SelfActions"], _fileForReinsertAction, true] call ace_interact_menu_fnc_addActionToClass;
|
||||
@@ -187,14 +185,19 @@ if (hasInterface) then {
|
||||
"\A3\ui_f\data\igui\cfg\simpleTasks\types\land_ca.paa",
|
||||
{
|
||||
params ["_target", "_player", "_params"];
|
||||
// send event to server
|
||||
["milsim_respawn_removeReinsertRequest", [_player]] call CBA_fnc_serverEvent;
|
||||
// notify player their request was rescinded
|
||||
"Re-insert Request Rescinded" call CBA_fnc_notify;
|
||||
},
|
||||
{
|
||||
params ["_target", "_player", "_params"];
|
||||
|
||||
private _existingQueue = missionNamespace getVariable ["milsim_respawn_reinsertionQueue", []];
|
||||
|
||||
// check if module is enabled, player is in the queue
|
||||
missionNamespace getVariable ["milsim_respawn_setting_reinsertion_enabled", true] &&
|
||||
(_player in ((missionNamespace getVariable ["milsim_respawn_reinsertionQueue", []]) apply {_x#0}))
|
||||
(_player in (_existingQueue apply {_x#0}))
|
||||
}
|
||||
] call ace_interact_menu_fnc_createAction;
|
||||
[_type, 1, ["ACE_SelfActions"], _removeFileForReinsertAction, true] call ace_interact_menu_fnc_addActionToClass;
|
||||
@@ -213,7 +216,7 @@ if (hasInterface) then {
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// PILOTS ONLY
|
||||
// PILOTS ONLY
|
||||
// ACE SELF-INTERACTIONS FOR CHECKING REINSERT QUEUE - ONLY FOR PILOTS
|
||||
localNamespace setVariable ["milsim_respawn_checkReinsertQueueClassesAdded", []];
|
||||
localNamespace setVariable ["milsim_respawn_lastReinsertQueueCheck", diag_tickTime];
|
||||
@@ -227,7 +230,7 @@ if (hasInterface) then {
|
||||
(localNamespace getVariable ["milsim_respawn_checkReinsertQueueClassesAdded", []])
|
||||
find _type != -1
|
||||
) exitWith {};
|
||||
|
||||
|
||||
private _checkReinsertQueueAction = [
|
||||
"milsim_respawn_checkReinsertQueue",
|
||||
"[PILOT] Check Re-insert Queue",
|
||||
@@ -267,13 +270,13 @@ if (hasInterface) then {
|
||||
)) exitWith {};
|
||||
private _lastCheck = localNamespace getVariable ["milsim_respawn_lastReinsertQueueCheck", diag_tickTime];
|
||||
if (
|
||||
diag_tickTime - _lastCheck <
|
||||
diag_tickTime - _lastCheck <
|
||||
missionNamespace getVariable ["milsim_respawn_setting_reinsertion_pilotForcedCheckInterval", 60*20]
|
||||
) exitWith {}; // if last check was less than X minutes ago, skip
|
||||
|
||||
// if last check was greater than 20 minutes ago, we'll prompt the notification now and reset the timer
|
||||
localNamespace setVariable ["milsim_respawn_lastReinsertQueueCheck", diag_tickTime];
|
||||
|
||||
|
||||
call milsim_respawn_fnc_showReinsertQueueNotification;
|
||||
}, 30] call CBA_fnc_addPerFrameHandler;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user