From 754d7356e112af1873ea119613e8f3b57a1da764 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Fri, 26 Jan 2024 00:26:06 -0800 Subject: [PATCH 1/5] adds events, queue, auto-notifications, manual checks for pilots --- functions/CfgFunctions.hpp | 8 + .../fbcb2/fn_messageFBCB2AssetStatus.sqf | 2 +- functions/respawn/fn_init.sqf | 182 ++++++++++++++++++ .../fn_showReinsertQueueNotification.sqf | 17 ++ 4 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 functions/respawn/fn_init.sqf create mode 100644 functions/respawn/fn_showReinsertQueueNotification.sqf diff --git a/functions/CfgFunctions.hpp b/functions/CfgFunctions.hpp index 04aa8f0..d88b58c 100644 --- a/functions/CfgFunctions.hpp +++ b/functions/CfgFunctions.hpp @@ -64,4 +64,12 @@ class milsim class mapMarkerToString {}; //needs refactor class stringToMapMarker {}; //needs refactor }; +}; + +class milsim_respawn { + class functions { + file = "functions\respawn"; + class init { postInit = 1; }; + class showReinsertQueueNotification {}; + }; }; \ No newline at end of file diff --git a/functions/fbcb2/fn_messageFBCB2AssetStatus.sqf b/functions/fbcb2/fn_messageFBCB2AssetStatus.sqf index abfc739..6571a0b 100644 --- a/functions/fbcb2/fn_messageFBCB2AssetStatus.sqf +++ b/functions/fbcb2/fn_messageFBCB2AssetStatus.sqf @@ -11,7 +11,7 @@ _text = composeText [_text, parseText "Asset Date: Fri, 26 Jan 2024 16:16:18 -0800 Subject: [PATCH 2/5] locally tested. adds settings, fixes removal logic --- functions/respawn/fn_init.sqf | 49 ++++++++++++++----- .../fn_showReinsertQueueNotification.sqf | 33 +++++++++++-- functions/settings/fn_addCBASettings.sqf | 37 ++++++++++++++ 3 files changed, 101 insertions(+), 18 deletions(-) diff --git a/functions/respawn/fn_init.sqf b/functions/respawn/fn_init.sqf index a6d6981..7ba95d1 100644 --- a/functions/respawn/fn_init.sqf +++ b/functions/respawn/fn_init.sqf @@ -1,8 +1,10 @@ // execute for all -milsim_respawn_setting_maxRangeToReady = 400; // distance in meters from a base at which players can ready up for pickup. players removed from the queue if they move further away than this distance +if (isNil "milsim_respawn_setting_reinsertion_maxRangeToReady") then { + // configured in CBA settings + milsim_respawn_setting_reinsertion_maxRangeToReady = 400; // distance in meters from a base at which players can ready up for pickup. players removed from the queue if they move further away than this distance +}; milsim_respawn_bases = allMissionObjects "ModuleRespawnPosition_F"; // array of all respawn modules in the mission -// player self-interacts will be applied in initPlayerLocal via milsim_respawn_fnc_readyForPickup // on the server, initialize the queue and register the CBA event handler by which players can ready up if (isServer) then { @@ -14,14 +16,19 @@ if (isServer) then { ["milsim_respawn_fileReinsertRequest", { params ["_unit", "_closestBaseName"]; milsim_respawn_reinsertionQueue pushBackUnique [_unit, _closestBaseName]; - diag_log text format ["[milsim_respawn] [reinsertion] ADDED name=%1 playerUID=%2 closestBase=%3", name _unit, getPlayerUID _unit, _closestBaseName]; + diag_log text format [ + "[milsim] (respawn_reinsertion) ADDED name=%1 playerUID=%2 closestBase=%3", + name _unit, getPlayerUID _unit, _closestBaseName + ]; publicVariable "milsim_respawn_reinsertionQueue"; }] call CBA_fnc_addEventHandler; ["milsim_respawn_removeReinsertRequest", { params ["_unit"]; - if (milsim_respawn_reinsertionQueue find {_x#0 isEqualTo _unit} == -1) exitWith {}; + if (count (milsim_respawn_reinsertionQueue select {_x#0 isEqualTo _unit}) isEqualTo 0) exitWith {}; milsim_respawn_reinsertionQueue = milsim_respawn_reinsertionQueue select {_x#0 isNotEqualTo _unit}; - diag_log text format ["[milsim_respawn] [reinsertion] REMOVED BY REQUEST name=%1 playerUID=%2", name _unit, getPlayerUID _unit]; + diag_log text format ["[milsim] (respawn_reinsertion) REMOVED BY REQUEST name=%1 playerUID=%2", + name _unit, getPlayerUID _unit + ]; publicVariable "milsim_respawn_reinsertionQueue"; }] call CBA_fnc_addEventHandler; @@ -41,7 +48,7 @@ if (isServer) then { if (_distanceFromBase < _nearestDistance) then { _nearestDistance = _distanceFromBase; }; - if (_distanceFromBase < milsim_respawn_setting_maxRangeToReady) then { + if (_distanceFromBase < milsim_respawn_setting_reinsertion_maxRangeToReady) then { _nearBase = true; }; } forEach milsim_respawn_bases; @@ -49,7 +56,10 @@ if (isServer) then { if (_nearBase && alive _player) then { _stillValid pushBackUnique _queueData; } else { - diag_log text format ["[milsim_respawn] [reinsertion] REMOVED AUTOMATICALLY name=%1 playerUID=%2 nearestBase=%3m", name _player, getPlayerUID _player, _nearestDistance]; + diag_log text format [ + "[milsim] (respawn_reinsertion) REMOVED AUTOMATICALLY name=%1 playerUID=%2 nearestBase=%3m", + name _player, getPlayerUID _player, _nearestDistance + ]; }; } forEach milsim_respawn_reinsertionQueue; @@ -81,13 +91,16 @@ if (hasInterface) then { { params ["_target", "_player", "_params"]; private _closestBase = [milsim_respawn_bases, _player] call BIS_fnc_nearestPosition; - ["milsim_respawn_fileReinsertRequest", [_player, _closestBase getVariable ["name", "unknown"]]] call CBA_fnc_serverEvent; - format["Re-insert Request Filed at Location %1", _closestBase getVariable ["name", "unknown"]] call CBA_fnc_notify; + private _closestBaseName = _closestBase getVariable ["name", "unknown"]; + ["milsim_respawn_fileReinsertRequest", [_player, _closestBaseName]] call CBA_fnc_serverEvent; + [["Re-insert Request Filed"], [format["Pickup at %1", _closestBaseName]]] call CBA_fnc_notify; }, { params ["_target", "_player", "_params"]; private _closestBase = [milsim_respawn_bases, _player] call BIS_fnc_nearestPosition; - (_player distance _closestBase < milsim_respawn_setting_maxRangeToReady) && + + 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})) } ] call ace_interact_menu_fnc_createAction; @@ -100,10 +113,12 @@ if (hasInterface) then { { params ["_target", "_player", "_params"]; ["milsim_respawn_removeReinsertRequest", [_player]] call CBA_fnc_serverEvent; - "Re-insert Request has been rescinded." call CBA_fnc_notify; + "Re-insert Request Rescinded" call CBA_fnc_notify; }, { params ["_target", "_player", "_params"]; + + missionNamespace getVariable ["milsim_respawn_setting_reinsertion_enabled", true] && (_player in ((missionNamespace getVariable ["milsim_respawn_reinsertionQueue", []]) apply {_x#0})) } ] call ace_interact_menu_fnc_createAction; @@ -149,7 +164,9 @@ if (hasInterface) then { call milsim_respawn_fnc_showReinsertQueueNotification; }, - {true} // always allow + { + missionNamespace getVariable ["milsim_respawn_setting_reinsertion_enabled", true] + } // always allow ] call ace_interact_menu_fnc_createAction; [_type, 1, ["ACE_SelfActions"], _checkReinsertQueueAction, true] call ace_interact_menu_fnc_addActionToClass; @@ -169,8 +186,14 @@ if (hasInterface) then { // ADD TIMER FOR PILOTS - IF REINSERT LIST NOT CHECKED FOR 20 MINUTES, SHOW NOTIFICATION AUTOMATICALLY if ((typeOf player) in ["B_Helipilot_F", "B_helicrew_F"]) then { [{ + if (not ( + missionNamespace getVariable ["milsim_respawn_setting_reinsertion_enabled", true] + )) exitWith {}; private _lastCheck = localNamespace getVariable ["milsim_respawn_lastReinsertQueueCheck", diag_tickTime]; - if (diag_tickTime - _lastCheck < (60*20)) exitWith {}; // if last check was less than 20 minutes ago, skip + if ( + 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]; diff --git a/functions/respawn/fn_showReinsertQueueNotification.sqf b/functions/respawn/fn_showReinsertQueueNotification.sqf index ce66ef7..4ae775c 100644 --- a/functions/respawn/fn_showReinsertQueueNotification.sqf +++ b/functions/respawn/fn_showReinsertQueueNotification.sqf @@ -2,14 +2,37 @@ private _par = [["Players Awaiting Reinsert", 1.2, [1,0.64,0,1]]]; private _baseNames = (missionNamespace getVariable ["milsim_respawn_reinsertionQueue", []]) apply {_x#1}; { private _baseName = _x; - _par pushBack [format ["Location: %1", _baseName], 1, [0,1,0,1]]; - { - _par pushBack _x; - } forEach ((missionNamespace getVariable ["milsim_respawn_reinsertionQueue", []]) select { + private _peopleAtThisBase = (missionNamespace getVariable ["milsim_respawn_reinsertionQueue", []]) select { _x#1 isEqualTo _baseName } apply { [name (_x#0), 0.7, [1,1,1,1]]; - }); + }; + + private _playerCountText = ""; + switch (count _peopleAtThisBase) do { + case 0: { + _playerCountText = "No players"; + }; + case 1: { + _playerCountText = "1 player"; + }; + default { + _playerCountText = format ["%1 players", count _peopleAtThisBase]; + }; + }; + + _par pushBack [ + format ["Location: %1 (%2)", + _baseName, + _playerCountText + ], + 1, + [0,1,0,1] + ]; + + { + _par pushBack _x; + } forEach _peopleAtThisBase; } forEach _baseNames; _par call CBA_fnc_notify; diff --git a/functions/settings/fn_addCBASettings.sqf b/functions/settings/fn_addCBASettings.sqf index dc0ef30..c19dd52 100644 --- a/functions/settings/fn_addCBASettings.sqf +++ b/functions/settings/fn_addCBASettings.sqf @@ -125,6 +125,43 @@ ] call CBA_fnc_addSetting; +//--------------------- +// Respawn Settings +[ + "milsim_respawn_setting_reinsertion_enabled", // variable + "CHECKBOX", // type + ["Enabled", "Whether or not players can file for reinsert and pilots can check the reinsert queue"], // title + ["17th Battalion", "Re-insert Queue"], // category + true, // default value + true, // global setting + { + params ["_value"]; + diag_log format["[milsim] (respawn_reinsertion) enabled set to %1", _value]; + } +] call CBA_fnc_addSetting; + +[ + "milsim_respawn_setting_reinsertion_maxRangeToReady", // variable + "SLIDER", // type + ["Max Request Filing Range", "Maximum distance from a respawn point a player can be to ready up"], // title + ["17th Battalion", "Re-insert Queue"], // category + [0, 1000, 400, 0, false], // [_min, _max, _default, _trailingDecimals, _isPercentage] + true, // global setting + { + params ["_value"]; + diag_log format["[milsim] (respawn_reinsertion) max range to ready set to %1", _value]; + } +] call CBA_fnc_addSetting; + +[ + "milsim_respawn_setting_reinsertion_pilotForcedCheckInterval", // variable + "SLIDER", // type + ["Pilot Check Interval", "Pilots will be force shown the queue if they haven't checked it in X seconds"], // 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"; nil; \ No newline at end of file -- 2.37.3.windows.1 From 4ced5080058327aafaeeca59679683e4be864ad3 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Fri, 26 Jan 2024 21:06:47 -0800 Subject: [PATCH 3/5] add global broadcast on players waiting longer than threshold, log --- functions/respawn/fn_init.sqf | 99 ++++++++++++++++++++---- functions/settings/fn_addCBASettings.sqf | 9 +++ 2 files changed, 93 insertions(+), 15 deletions(-) diff --git a/functions/respawn/fn_init.sqf b/functions/respawn/fn_init.sqf index 7ba95d1..44cee2d 100644 --- a/functions/respawn/fn_init.sqf +++ b/functions/respawn/fn_init.sqf @@ -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 if (isNil "milsim_respawn_setting_reinsertion_maxRangeToReady") then { // configured in CBA settings @@ -12,34 +18,49 @@ if (isServer) then { milsim_respawn_reinsertionQueue = []; publicVariable "milsim_respawn_reinsertionQueue"; + milsim_respawn_reinsertionOverTimeoutLastNotificationTime = 0; + // register event handlers ["milsim_respawn_fileReinsertRequest", { - params ["_unit", "_closestBaseName"]; - milsim_respawn_reinsertionQueue pushBackUnique [_unit, _closestBaseName]; + params ["_unit", "_closestBaseName", "_time"]; + milsim_respawn_reinsertionQueue pushBackUnique [_unit, _closestBaseName, _time]; diag_log text format [ - "[milsim] (respawn_reinsertion) ADDED name=%1 playerUID=%2 closestBase=%3", - name _unit, getPlayerUID _unit, _closestBaseName + "[milsim] (respawn_reinsertion) ADDED name=%1 playerUID=%2 filedAtBase=%3", + name _unit, + getPlayerUID _unit, + _closestBaseName ]; publicVariable "milsim_respawn_reinsertionQueue"; }] call CBA_fnc_addEventHandler; ["milsim_respawn_removeReinsertRequest", { params ["_unit"]; - if (count (milsim_respawn_reinsertionQueue select {_x#0 isEqualTo _unit}) isEqualTo 0) exitWith {}; - milsim_respawn_reinsertionQueue = milsim_respawn_reinsertionQueue select {_x#0 isNotEqualTo _unit}; - diag_log text format ["[milsim] (respawn_reinsertion) REMOVED BY REQUEST name=%1 playerUID=%2", - name _unit, getPlayerUID _unit + private _unitArrs = milsim_respawn_reinsertionQueue select {_x#0 isEqualTo _unit}; + if (count _unitArrs isEqualTo 0) exitWith {}; + + 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"; }] call CBA_fnc_addEventHandler; - // 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) + [{ + // 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 _queueData = _x; - private _player = _queueData#0; + _x params ["_player", "_baseName", "_timeFiled"]; // _unitArr = [unit, baseName, timeInQueue] private _nearBase = false; private _nearestDistance = 99999; { @@ -57,14 +78,62 @@ if (isServer) then { _stillValid pushBackUnique _queueData; } else { diag_log text format [ - "[milsim] (respawn_reinsertion) REMOVED AUTOMATICALLY name=%1 playerUID=%2 nearestBase=%3m", - name _player, getPlayerUID _player, _nearestDistance + "[milsim] (respawn_reinsertion) REMOVED AUTOMATICALLY name=%1 playerUID=%2 filedAtBase=%3 nearestBaseDistance=%4m inQueue=%5s", + name _unit, + getPlayerUID _unit, + _baseName, + _nearestDistance, + diag_tickTime - _timeFiled ]; }; } forEach milsim_respawn_reinsertionQueue; + // broadcast new list to all machines milsim_respawn_reinsertionQueue = _stillValid; 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; }; @@ -92,7 +161,7 @@ if (hasInterface) then { params ["_target", "_player", "_params"]; private _closestBase = [milsim_respawn_bases, _player] call BIS_fnc_nearestPosition; 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; }, { diff --git a/functions/settings/fn_addCBASettings.sqf b/functions/settings/fn_addCBASettings.sqf index c19dd52..7b87c51 100644 --- a/functions/settings/fn_addCBASettings.sqf +++ b/functions/settings/fn_addCBASettings.sqf @@ -162,6 +162,15 @@ true ] 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"; nil; \ No newline at end of file -- 2.37.3.windows.1 From e395fa9c16478a974e60821b35025f79df2422d5 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Fri, 26 Jan 2024 21:22:35 -0800 Subject: [PATCH 4/5] add forcedPilotCheck setting, some formatting changes --- functions/respawn/fn_init.sqf | 5 +++-- functions/settings/fn_addCBASettings.sqf | 28 +++++++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/functions/respawn/fn_init.sqf b/functions/respawn/fn_init.sqf index 44cee2d..59aec70 100644 --- a/functions/respawn/fn_init.sqf +++ b/functions/respawn/fn_init.sqf @@ -256,7 +256,8 @@ if (hasInterface) then { if ((typeOf player) in ["B_Helipilot_F", "B_helicrew_F"]) then { [{ if (not ( - missionNamespace getVariable ["milsim_respawn_setting_reinsertion_enabled", true] + missionNamespace getVariable ["milsim_respawn_setting_reinsertion_enabled", true] && + missionNamespace getVariable ["milsim_respawn_setting_reinsertion_pilotForcedCheckEnabled", true] )) exitWith {}; private _lastCheck = localNamespace getVariable ["milsim_respawn_lastReinsertQueueCheck", diag_tickTime]; if ( @@ -266,7 +267,7 @@ if (hasInterface) then { // 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; }; diff --git a/functions/settings/fn_addCBASettings.sqf b/functions/settings/fn_addCBASettings.sqf index 7b87c51..c541b2b 100644 --- a/functions/settings/fn_addCBASettings.sqf +++ b/functions/settings/fn_addCBASettings.sqf @@ -149,7 +149,20 @@ true, // global setting { params ["_value"]; - diag_log format["[milsim] (respawn_reinsertion) max range to ready set to %1", _value]; + diag_log format["[milsim] (respawn_reinsertion) maxRangeToReady set to %1", _value]; + } +] call CBA_fnc_addSetting; + +[ + "milsim_respawn_setting_reinsertion_pilotForcedCheckEnabled", // variable + "CHECKBOX", // type + ["Enabled", "Whether or not pilots are forced to view the contents of the reinsertion queue per interval"], // title + ["17th Battalion", "Re-insert Queue"], // category + true, // default value + true, // global setting + { + params ["_value"]; + diag_log format["[milsim] (respawn_reinsertion) pilotForcedCheckEnabled set to %1", _value]; } ] call CBA_fnc_addSetting; @@ -159,7 +172,12 @@ ["Pilot Check Interval", "Pilots will be force shown the queue if they haven't checked it in X seconds"], // title ["17th Battalion", "Re-insert Queue"], // category [60*10, 60*30, 60*20, 0, false], // [_min, _max, _default, _trailingDecimals, _isPercentage - true + true, + { + params ["_value"]; + diag_log format["[milsim] (respawn_reinsertion) pilotForcedCheckInterval set to %1", _value]; + + } ] call CBA_fnc_addSetting; [ @@ -168,7 +186,11 @@ ["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 + true, + { + params ["_value"]; + diag_log format["[milsim] (respawn_reinsertion) timeout set to %1", _value]; + } ] call CBA_fnc_addSetting; diag_log text "[MILSIM] (settings) Custom CBA settings initialized"; -- 2.37.3.windows.1 From 1ac1664faf4bc0261d5e38cd56f1683937285e7a Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Sun, 28 Jan 2024 13:46:56 -0800 Subject: [PATCH 5/5] bug fixes --- functions/respawn/fn_init.sqf | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/functions/respawn/fn_init.sqf b/functions/respawn/fn_init.sqf index 59aec70..762dca0 100644 --- a/functions/respawn/fn_init.sqf +++ b/functions/respawn/fn_init.sqf @@ -61,7 +61,6 @@ if (isServer) then { private _stillValid = []; { _x params ["_player", "_baseName", "_timeFiled"]; // _unitArr = [unit, baseName, timeInQueue] - private _nearBase = false; private _nearestDistance = 99999; { private _baseLocation = _x; @@ -69,18 +68,17 @@ if (isServer) then { if (_distanceFromBase < _nearestDistance) then { _nearestDistance = _distanceFromBase; }; - if (_distanceFromBase < milsim_respawn_setting_reinsertion_maxRangeToReady) then { - _nearBase = true; - }; } forEach milsim_respawn_bases; + private _nearBase = _nearestDistance < milsim_respawn_setting_reinsertion_maxRangeToReady; + if (_nearBase && alive _player) then { - _stillValid pushBackUnique _queueData; + _stillValid pushBackUnique _x; } else { diag_log text format [ "[milsim] (respawn_reinsertion) REMOVED AUTOMATICALLY name=%1 playerUID=%2 filedAtBase=%3 nearestBaseDistance=%4m inQueue=%5s", - name _unit, - getPlayerUID _unit, + name _player, + getPlayerUID _player, _baseName, _nearestDistance, diag_tickTime - _timeFiled @@ -96,7 +94,7 @@ 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 = - diag_tickTime - milsim_respawn_reinsertionOverTimeoutLastNotificationTime > 60*5 // if last notification was more than 5 minutes ago + 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}; @@ -160,7 +158,8 @@ if (hasInterface) then { { params ["_target", "_player", "_params"]; private _closestBase = [milsim_respawn_bases, _player] call BIS_fnc_nearestPosition; - private _closestBaseName = _closestBase getVariable ["name", "unknown"]; + 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; }, -- 2.37.3.windows.1