Merge pull request 'improve inventory check performance and logging' (#10) from #7-inventory-compliance-message into inv_expan
Reviewed-on: https://17th-gs.iceberg-gaming.com:5443/hizumi/MissionTemplate/pulls/10
This commit was merged in pull request #10.
This commit is contained in:
@@ -39,11 +39,13 @@ addMissionEventHandler ["HandleChatMessage",
|
||||
|
||||
|
||||
["ace_arsenal_displayClosed", {
|
||||
player remoteExec["milsim_fnc_logPlayerInventory", 0];
|
||||
private _lines = [player] call milsim_fnc_logPlayerInventory;
|
||||
["milsim_logText", [_lines]] call CBA_fnc_globalEvent;
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
[missionNamespace, "arsenalClosed", {
|
||||
player remoteExec["milsim_fnc_logPlayerInventory", 0];
|
||||
private _lines = [player] call milsim_fnc_logPlayerInventory;
|
||||
["milsim_logText", [_lines]] call CBA_fnc_globalEvent;
|
||||
}] call BIS_fnc_addScriptedEventHandler;
|
||||
|
||||
diag_log text "[MILSIM] (client) event handlers bound";
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
if ( !hasInterface ) exitWith {};
|
||||
|
||||
if (!isServer) then {
|
||||
["milsim_logText", {
|
||||
params [["_strArray", [""], [[]]]];
|
||||
{
|
||||
diag_log text _x;
|
||||
} forEach _strArray;
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
};
|
||||
|
||||
["InitializePlayer", [player, true]] call BIS_fnc_dynamicGroups;
|
||||
|
||||
nil;
|
||||
@@ -53,7 +53,12 @@ publicVariable "milsim_var_rotaryAssets";
|
||||
// Initializes the Dynamic Groups framework and groups
|
||||
["Initialize", [true]] call BIS_fnc_dynamicGroups;
|
||||
|
||||
|
||||
["milsim_logText", {
|
||||
params [["_strArray", [""], [[]]]];
|
||||
{
|
||||
diag_log text _x;
|
||||
} forEach _strArray;
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
missionNamespace setVariable ["milsim_complete", true];
|
||||
diag_log text "[MILSIM] (initServer) milsim_complete: version 2.3";
|
||||
|
||||
@@ -1,39 +1,28 @@
|
||||
/*
|
||||
Function: milsim_fnc_logPlayerInventory
|
||||
|
||||
Description:
|
||||
Checks a player's inventory for non-compliant items and logs results to all machines.
|
||||
|
||||
Author: Hizumi, EagleTrooper, IndigoFox
|
||||
|
||||
Parameters:
|
||||
0: _player - <OBJECT> - Player to check inventory of.
|
||||
|
||||
Returns:
|
||||
<ARRAY> - Array of strings to be logged.
|
||||
|
||||
*/
|
||||
params [
|
||||
["_player", objNull, [objNull]]
|
||||
];
|
||||
|
||||
if (!isPlayer _player) exitWith { diag_log("exitWith logPlayerInventory")};
|
||||
if (!isPlayer _player) exitWith {
|
||||
["[MILSIM] (logPlayerInventory): ERROR :: _player is not a player"]
|
||||
};
|
||||
|
||||
_items = [];
|
||||
_ietms pushback headgear _player;
|
||||
_items pushback uniform _player;
|
||||
_items append uniformItems _player;
|
||||
_items pushback vest _player;
|
||||
_items append vestItems _player;
|
||||
_items pushback backpack _player;
|
||||
_items append backpackItems _player;
|
||||
_items pushback hmd _player;
|
||||
_items pushback binocular _player;
|
||||
_items pushback primaryWeapon _player;
|
||||
_items append primaryWeaponItems _player;
|
||||
_items pushback secondaryWeapon _player;
|
||||
_items append secondaryWeaponItems _player;
|
||||
|
||||
|
||||
|
||||
_unlisted = [];
|
||||
|
||||
_restricted = [];
|
||||
_blacklist = [];
|
||||
_tabbed = [];
|
||||
_meme = [];
|
||||
|
||||
diag_log text format["[MILSIM] (logPlayerInventory): Checking %1 inventory.", name _player];
|
||||
|
||||
{
|
||||
|
||||
_blackListItems = [ // Items that NO member is allowed to use.
|
||||
// DEFINITIONS
|
||||
_blackListItems = [ // Items that NO member is allowed to use.
|
||||
"17BN_ANPVS14", // NVG AN/PVS-14
|
||||
"USP_PVS_14", // NVG AN/PVS-14
|
||||
"USP_PVS_15", // NVG AN/PVS-15
|
||||
@@ -131,9 +120,9 @@ diag_log text format["[MILSIM] (logPlayerInventory): Checking %1 inventory.", na
|
||||
"SMA_ACRREMGL", //Remington ACR 556+6.5
|
||||
"LMG_Mk200_F", //Mk200 Series
|
||||
"LMG_Mk200_black_F" //Mk200 Series
|
||||
]
|
||||
];
|
||||
|
||||
_restrictedItems = [ // Items that are allowed for Specific USE Case (RRC / Marksman / etc.)
|
||||
_restrictedItems = [ // Items that are allowed for Specific USE Case (RRC / Marksman / etc.)
|
||||
"A3_GPNVG18b_REC_TI", // Thermal Quad
|
||||
"A3_GPNVG18_REC_TI", // Thermal Quad
|
||||
"A3_GPNVG18b_TI", // Thermal Quad
|
||||
@@ -172,9 +161,9 @@ diag_log text format["[MILSIM] (logPlayerInventory): Checking %1 inventory.", na
|
||||
"optic_lrps_tna_F", //Nightforce Series Optic
|
||||
"ACE_optic_LRPS_2D", //Nightforce Series Optic
|
||||
"ACE_optic_LRPS_PIP" //Nightforce Series Optic
|
||||
];
|
||||
];
|
||||
|
||||
_tabbedItems = [ // Items that are allowed for individuals with Ranger Tab
|
||||
_tabbedItems = [ // Items that are allowed for individuals with Ranger Tab
|
||||
"arifle_SPAR_03_snd_F", // HK417 Series
|
||||
"arifle_SPAR_03_blk_F", // HK417 Series
|
||||
"arifle_SPAR_03_khk_F", // HK417 Series
|
||||
@@ -224,21 +213,81 @@ diag_log text format["[MILSIM] (logPlayerInventory): Checking %1 inventory.", na
|
||||
"Tier1_MK48_Mod0_Para_Desert", // Mk48 Series
|
||||
"Tier1_MK48_Mod1", // Mk48 Series
|
||||
"Tier1_MK48_Mod1_Desert" // Mk48 Series
|
||||
]
|
||||
];
|
||||
|
||||
_memeItems = [ // Items that serve no purpose other than to MEME
|
||||
_memeItems = [ // Items that serve no purpose other than to MEME
|
||||
"UK3CB_Cocaine_Brick",
|
||||
"ACE_Banana"
|
||||
]
|
||||
|
||||
];
|
||||
|
||||
|
||||
// INSTANTIATE VARS
|
||||
private _returnLines = [];
|
||||
|
||||
_unlisted = [];
|
||||
|
||||
_restricted = [];
|
||||
_blacklist = [];
|
||||
_tabbed = [];
|
||||
_meme = [];
|
||||
|
||||
private _nonCompliantItemsCount = 0;
|
||||
|
||||
// PRIVATE FUNCTIONS
|
||||
private _logItem = {
|
||||
params ["_playerObj", "_categoryText", "_itemClassName"];
|
||||
private _cfg = _itemClassName call CBA_fnc_getItemConfig;
|
||||
_returnLines pushBack (format[
|
||||
"[MILSIM] (logPlayerInventory): %1 :: className=""%2"" displayName=""%3"" %4",
|
||||
_categoryText,
|
||||
_itemClassName,
|
||||
[_cfg] call BIS_fnc_displayName,
|
||||
[_playerObj] call _playerInfoString
|
||||
]);
|
||||
};
|
||||
|
||||
private _playerInfoString = {
|
||||
params ["_playerObj"];
|
||||
format["playerName=""%1"" playerUID=""%2"" playerGroup=""%3""", name _playerObj, getPlayerUID _playerObj, groupId (group _playerObj)];
|
||||
};
|
||||
|
||||
|
||||
// GATHER INVENTORY
|
||||
// _items = [];
|
||||
// _items pushback headgear _player;
|
||||
// _items pushback uniform _player;
|
||||
// _items append uniformItems _player;
|
||||
// _items pushback vest _player;
|
||||
// _items append vestItems _player;
|
||||
// _items pushback backpack _player;
|
||||
// _items append backpackItems _player;
|
||||
// _items pushback hmd _player;
|
||||
// _items pushback binocular _player;
|
||||
// _items pushback primaryWeapon _player;
|
||||
// _items append primaryWeaponItems _player;
|
||||
// _items pushback secondaryWeapon _player;
|
||||
// _items append secondaryWeaponItems _player;
|
||||
|
||||
_items = [
|
||||
_player, // Unit
|
||||
true, // Include weapons, attachments, loaded magazines
|
||||
true, // Include items in backpack
|
||||
true, // Include items in vest
|
||||
true, // Include items in uniform
|
||||
true, // Include assigned items
|
||||
true // Include not loaded magazines
|
||||
] call CBA_fnc_uniqueUnitItems;
|
||||
|
||||
_items pushBack (headgear _player);
|
||||
_items pushBack (uniform _player);
|
||||
|
||||
// CHECK INVENTORY
|
||||
_returnLines pushBack (format[
|
||||
"[MILSIM] (logPlayerInventory): CHECKING :: %1",
|
||||
[_player] call _playerInfoString
|
||||
]);
|
||||
|
||||
{
|
||||
_item = _x;
|
||||
_modes = getArray(configfile >> "CfgWeapons" >> _item >> "visionMode");
|
||||
|
||||
@@ -254,7 +303,7 @@ diag_log text format["[MILSIM] (logPlayerInventory): Checking %1 inventory.", na
|
||||
};
|
||||
|
||||
if ( _item in _restrictedItems ) then {
|
||||
_restrcited pushBackUnique _item;
|
||||
_restricted pushBackUnique _item;
|
||||
};
|
||||
|
||||
if ( _item in _tabbedItems ) then {
|
||||
@@ -274,28 +323,44 @@ diag_log text format["[MILSIM] (logPlayerInventory): Checking %1 inventory.", na
|
||||
|
||||
} forEach _items;
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
diag_log text format["[MILSIM] (logPlayerInventory): %1 has a blacklisted inventory item: %2", name _player, getText( configfile >> "CfgWeapons" >> _x >> "displayName" )];
|
||||
_nonCompliantItemsCount = _nonCompliantItemsCount + 1;
|
||||
[_player, "BLACKLISTED", _x] call _logItem;
|
||||
} forEach _blacklist;
|
||||
|
||||
{
|
||||
diag_log text format["[MILSIM] (logPlayerInventory): %1 has a restricted inventory item: %2", name _player, getText( configfile >> "CfgWeapons" >> _x >> "displayName" )];
|
||||
} forEach _restrcited;
|
||||
_nonCompliantItemsCount = _nonCompliantItemsCount + 1;
|
||||
[_player, "RESTRICTED", _x] call _logItem;
|
||||
} forEach _restricted;
|
||||
|
||||
{
|
||||
diag_log text format["[MILSIM] (logPlayerInventory): %1 has a tabbed inventory item: %2", name _player, getText( configfile >> "CfgWeapons" >> _x >> "displayName" )];
|
||||
_nonCompliantItemsCount = _nonCompliantItemsCount + 1;
|
||||
[_player, "TABBED", _x] call _logItem;
|
||||
} forEach _tabbed;
|
||||
|
||||
{
|
||||
diag_log text format["[MILSIM] (logPlayerInventory): %1 has a meme inventory item: %2", name _player, getText( configfile >> "CfgWeapons" >> _x >> "displayName" )];
|
||||
_nonCompliantItemsCount = _nonCompliantItemsCount + 1;
|
||||
[_player, "MEME", _x] call _logItem;
|
||||
} forEach _meme;
|
||||
|
||||
{
|
||||
diag_log text format["[MILSIM] (logPlayerInventory): %1 has an unlisted thermal item: %2", name _player, getText( configfile >> "CfgWeapons" >> _x >> "displayName" )];
|
||||
if (
|
||||
_x in _blackListItems ||
|
||||
_x in _restrictedItems
|
||||
) then {continue}; // Skip items that are already checked
|
||||
_nonCompliantItemsCount = _nonCompliantItemsCount + 1;
|
||||
[_player, "UNLISTED THERMAL", _x] call _logItem;
|
||||
} forEach _unlisted;
|
||||
|
||||
if (((count _blacklist) isEqualTo 0) && ((count _restrcited) isEqualTo 0) && ((count _tabbed) isEqualTo 0) && ((count _meme) isEqualTo 0) && ((count _unlisted) isEqualTo 0)) then {
|
||||
diag_log text format["[MILSIM] (logPlayerInventory): %1 inventory in fully base inventory compliant.", name _player];
|
||||
}
|
||||
if (_nonCompliantItemsCount isEqualTo 0) then {
|
||||
_returnLines pushBack (format[
|
||||
"[MILSIM] (logPlayerInventory): COMPLIANT :: %1",
|
||||
[_player] call _playerInfoString
|
||||
]);
|
||||
};
|
||||
|
||||
nil
|
||||
// returns array of strings
|
||||
_returnLines;
|
||||
Reference in New Issue
Block a user