From cada98e15a5f7d52675d4932cd89437789611b92 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Mon, 29 Jan 2024 13:48:35 -0800 Subject: [PATCH] change logPlayerInventory to return lines, which handlers send to CBA ev --- functions/client/fn_bindEventHandlers.sqf | 6 ++-- functions/init/fn_initPlayerLocal.sqf | 9 ++++++ functions/init/fn_initServer.sqf | 7 ++++- functions/server/fn_logPlayerInventory.sqf | 35 +++++++++++++++++----- 4 files changed, 46 insertions(+), 11 deletions(-) diff --git a/functions/client/fn_bindEventHandlers.sqf b/functions/client/fn_bindEventHandlers.sqf index 08a8cdf..f04d505 100644 --- a/functions/client/fn_bindEventHandlers.sqf +++ b/functions/client/fn_bindEventHandlers.sqf @@ -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"; diff --git a/functions/init/fn_initPlayerLocal.sqf b/functions/init/fn_initPlayerLocal.sqf index 3a1a2a3..d72495f 100644 --- a/functions/init/fn_initPlayerLocal.sqf +++ b/functions/init/fn_initPlayerLocal.sqf @@ -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; \ No newline at end of file diff --git a/functions/init/fn_initServer.sqf b/functions/init/fn_initServer.sqf index 15784ef..c2c335e 100644 --- a/functions/init/fn_initServer.sqf +++ b/functions/init/fn_initServer.sqf @@ -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"; diff --git a/functions/server/fn_logPlayerInventory.sqf b/functions/server/fn_logPlayerInventory.sqf index 5ea5997..b85f0f5 100644 --- a/functions/server/fn_logPlayerInventory.sqf +++ b/functions/server/fn_logPlayerInventory.sqf @@ -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 - - Player to check inventory of. + + Returns: + - 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"] +}; // DEFINITIONS _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 +private _returnLines = []; + _unlisted = []; _restricted = []; @@ -219,13 +237,13 @@ private _nonCompliantItemsCount = 0; private _logItem = { params ["_playerObj", "_categoryText", "_itemClassName"]; private _cfg = _itemClassName call CBA_fnc_getItemConfig; - diag_log text format[ + _returnLines pushBack (format[ "[MILSIM] (logPlayerInventory): %1 :: className=""%2"" displayName=""%3"" %4", _categoryText, _itemClassName, [_cfg] call BIS_fnc_displayName, [_playerObj] call _playerInfoString - ]; + ]); }; private _playerInfoString = { @@ -264,10 +282,10 @@ _items pushBack (headgear _player); _items pushBack (uniform _player); // CHECK INVENTORY -diag_log text format[ +_returnLines pushBack (format[ "[MILSIM] (logPlayerInventory): CHECKING :: %1", [_player] call _playerInfoString -]; +]); { _item = _x; @@ -338,10 +356,11 @@ diag_log text format[ } forEach _unlisted; if (_nonCompliantItemsCount isEqualTo 0) then { - diag_log text format[ + _returnLines pushBack (format[ "[MILSIM] (logPlayerInventory): COMPLIANT :: %1", [_player] call _playerInfoString - ]; + ]); }; -nil \ No newline at end of file +// returns array of strings +_returnLines; \ No newline at end of file