change logPlayerInventory to return lines, which handlers send to CBA ev #12

Merged
hizumi merged 1 commits from #11-inventory-processed-on-every-machine into #7-inventory-compliance-message 2024-01-29 23:36:42 -06:00
4 changed files with 46 additions and 11 deletions
Showing only changes of commit cada98e15a - Show all commits

View File

@@ -39,11 +39,13 @@ addMissionEventHandler ["HandleChatMessage",
["ace_arsenal_displayClosed", { ["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; }] call CBA_fnc_addEventHandler;
[missionNamespace, "arsenalClosed", { [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; }] call BIS_fnc_addScriptedEventHandler;
diag_log text "[MILSIM] (client) event handlers bound"; diag_log text "[MILSIM] (client) event handlers bound";

View File

@@ -1,5 +1,14 @@
if ( !hasInterface ) exitWith {}; 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; ["InitializePlayer", [player, true]] call BIS_fnc_dynamicGroups;
nil; nil;

View File

@@ -53,7 +53,12 @@ publicVariable "milsim_var_rotaryAssets";
// Initializes the Dynamic Groups framework and groups // Initializes the Dynamic Groups framework and groups
["Initialize", [true]] call BIS_fnc_dynamicGroups; ["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]; missionNamespace setVariable ["milsim_complete", true];
diag_log text "[MILSIM] (initServer) milsim_complete: version 2.3"; diag_log text "[MILSIM] (initServer) milsim_complete: version 2.3";

View File

@@ -1,9 +1,25 @@
/*
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 [ params [
["_player", objNull, [objNull]] ["_player", objNull, [objNull]]
]; ];
if (!isPlayer _player) exitWith { diag_log("exitWith logPlayerInventory")}; if (!isPlayer _player) exitWith {
["[MILSIM] (logPlayerInventory): ERROR :: _player is not a player"]
};
// DEFINITIONS // DEFINITIONS
_blackListItems = [ // Items that NO member is allowed to use. _blackListItems = [ // Items that NO member is allowed to use.
@@ -206,6 +222,8 @@ _memeItems = [ // Items that serve no purpose other than to MEME
// INSTANTIATE VARS // INSTANTIATE VARS
private _returnLines = [];
_unlisted = []; _unlisted = [];
_restricted = []; _restricted = [];
@@ -219,13 +237,13 @@ private _nonCompliantItemsCount = 0;
private _logItem = { private _logItem = {
params ["_playerObj", "_categoryText", "_itemClassName"]; params ["_playerObj", "_categoryText", "_itemClassName"];
private _cfg = _itemClassName call CBA_fnc_getItemConfig; private _cfg = _itemClassName call CBA_fnc_getItemConfig;
diag_log text format[ _returnLines pushBack (format[
"[MILSIM] (logPlayerInventory): %1 :: className=""%2"" displayName=""%3"" %4", "[MILSIM] (logPlayerInventory): %1 :: className=""%2"" displayName=""%3"" %4",
_categoryText, _categoryText,
_itemClassName, _itemClassName,
[_cfg] call BIS_fnc_displayName, [_cfg] call BIS_fnc_displayName,
[_playerObj] call _playerInfoString [_playerObj] call _playerInfoString
]; ]);
}; };
private _playerInfoString = { private _playerInfoString = {
@@ -264,10 +282,10 @@ _items pushBack (headgear _player);
_items pushBack (uniform _player); _items pushBack (uniform _player);
// CHECK INVENTORY // CHECK INVENTORY
diag_log text format[ _returnLines pushBack (format[
"[MILSIM] (logPlayerInventory): CHECKING :: %1", "[MILSIM] (logPlayerInventory): CHECKING :: %1",
[_player] call _playerInfoString [_player] call _playerInfoString
]; ]);
{ {
_item = _x; _item = _x;
@@ -338,10 +356,11 @@ diag_log text format[
} forEach _unlisted; } forEach _unlisted;
if (_nonCompliantItemsCount isEqualTo 0) then { if (_nonCompliantItemsCount isEqualTo 0) then {
diag_log text format[ _returnLines pushBack (format[
"[MILSIM] (logPlayerInventory): COMPLIANT :: %1", "[MILSIM] (logPlayerInventory): COMPLIANT :: %1",
[_player] call _playerInfoString [_player] call _playerInfoString
]; ]);
}; };
nil // returns array of strings
_returnLines;