big refactor to isolate functionality. adds milsim_fnc_log.
This commit is contained in:
11
functions/util/fn_addPlayerInfoToArray.sqf
Normal file
11
functions/util/fn_addPlayerInfoToArray.sqf
Normal file
@@ -0,0 +1,11 @@
|
||||
params [["_playerObj", objNull], ["_arrayToModify", [], [[]]]];
|
||||
|
||||
{
|
||||
_arrayToModify = [_arrayToModify, _x#0, _x#1] call BIS_fnc_setToPairs;
|
||||
} forEach [
|
||||
["playerName", name _playerObj],
|
||||
["playerUID", getPlayerUID _playerObj],
|
||||
["playerGroup", groupId (group _playerObj)]
|
||||
];
|
||||
|
||||
_arrayToModify;
|
||||
@@ -8,10 +8,35 @@
|
||||
|
||||
Parameters:
|
||||
0: _playerObj <OBJECT> - The player object to get the string for.
|
||||
1: _returnArray <BOOL> - If true, returns a key/value array of the player's name, UID and group name.
|
||||
*/
|
||||
|
||||
params [["_playerObj", objNull]];
|
||||
if (isNull _playerObj) exitWith {
|
||||
"playerName=""ERROR"" playerUID=""ERROR"" playerGroup=""ERROR"""
|
||||
params [["_playerObj", objNull], ["_returnArray", false, [false, true]]];
|
||||
|
||||
switch (_returnArray) do {
|
||||
case false: {
|
||||
if (isNull _playerObj) exitWith {
|
||||
"playerName=""ERROR"" playerUID=""ERROR"" playerGroup=""ERROR"""
|
||||
};
|
||||
if (true) exitWith {
|
||||
format["playerName=""%1"" playerUID=""%2"" playerGroup=""%3""", name _playerObj, getPlayerUID _playerObj, groupId (group _playerObj)];
|
||||
};
|
||||
};
|
||||
case true: {
|
||||
if (isNull _playerObj) exitWith {
|
||||
[
|
||||
["playerName", "ERROR"],
|
||||
["playerUID", "ERROR"],
|
||||
["playerGroup", "ERROR"]
|
||||
]
|
||||
};
|
||||
if (true) exitWith {
|
||||
[
|
||||
["playerName", name _playerObj],
|
||||
["playerUID", getPlayerUID _playerObj],
|
||||
["playerGroup", groupId (group _playerObj)]
|
||||
]
|
||||
};
|
||||
};
|
||||
};
|
||||
format["playerName=""%1"" playerUID=""%2"" playerGroup=""%3""", name _playerObj, getPlayerUID _playerObj, groupId (group _playerObj)];
|
||||
|
||||
|
||||
24
functions/util/fn_log.sqf
Normal file
24
functions/util/fn_log.sqf
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
Function: milsim_fnc_log
|
||||
|
||||
Description:
|
||||
Used to log messages to the server RPT file.
|
||||
|
||||
Parameters:
|
||||
0: STRING - component name.
|
||||
1: STRING - message to log.
|
||||
2: ARRAY - Key value pairs of data to log.
|
||||
*/
|
||||
|
||||
params [
|
||||
["_component", "", [""]],
|
||||
["_message", "", [""]],
|
||||
["_data", [], [[]]]
|
||||
];
|
||||
|
||||
private _hash = createHashMapFromArray _data;
|
||||
|
||||
private _json = [_hash] call CBA_fnc_encodeJSON;
|
||||
_log = format ["[milsim] (%1) (%2) (%3) :: %4", _component, _fnc_scriptNameParent, _message, _json];
|
||||
|
||||
diag_log text _log;
|
||||
Reference in New Issue
Block a user