locally tested. adds settings, fixes removal logic
This commit is contained in:
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user