2018-07-30 09:22:14 +00:00
|
|
|
#include "script_component.hpp"
|
2016-07-15 10:23:47 +00:00
|
|
|
/*
|
2019-06-03 15:31:46 +00:00
|
|
|
* Author: Glowbal, mharis001
|
|
|
|
* Adds an entry to the specified medical log of the unit.
|
2016-07-15 10:23:47 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2019-06-03 15:31:46 +00:00
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Log Type <STRING>
|
|
|
|
* 2: Message <STRING>
|
|
|
|
* 3: Formatting Arguments <ARRAY>
|
2016-07-15 10:23:47 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
2019-06-03 15:31:46 +00:00
|
|
|
* [player, "activity", "Message %1", ["Name"]] call ace_medical_treatment_fnc_addToLog
|
2017-06-08 13:31:51 +00:00
|
|
|
*
|
2019-03-30 16:07:54 +00:00
|
|
|
* Public: No
|
2016-07-15 10:23:47 +00:00
|
|
|
*/
|
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
params ["_unit", "_logType", "_message", "_arguments"];
|
2016-07-15 10:23:47 +00:00
|
|
|
|
|
|
|
if (!local _unit) exitWith {
|
2019-06-03 15:31:46 +00:00
|
|
|
[QGVAR(addToLog), _this, _unit] call CBA_fnc_targetEvent;
|
2016-07-15 10:23:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
date params ["", "", "", "_hour", "_minute"];
|
2019-06-03 15:31:46 +00:00
|
|
|
private _timeStamp = format ["%1:%2", _hour, [_minute, 2] call CBA_fnc_formatNumber];
|
2016-07-15 10:23:47 +00:00
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
private _logVarName = MED_LOG_VARNAME(_logType);
|
2016-07-15 10:23:47 +00:00
|
|
|
private _log = _unit getVariable [_logVarName, []];
|
2016-10-13 19:21:42 +00:00
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
if (count _log >= MED_LOG_MAX_ENTRIES) then {
|
|
|
|
_log deleteAt 0;
|
2016-07-15 10:23:47 +00:00
|
|
|
};
|
2016-10-13 19:21:42 +00:00
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
_log pushBack [_message, _timeStamp, _arguments, _logType];
|
2016-07-15 10:23:47 +00:00
|
|
|
_unit setVariable [_logVarName, _log, true];
|
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
private _allLogs = _unit getVariable [QEGVAR(medical,allLogs), []];
|
2016-10-13 19:21:42 +00:00
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
if !(_logVarName in _allLogs) then {
|
|
|
|
_allLogs pushBack _logVarName;
|
|
|
|
_unit setVariable [QEGVAR(medical,allLogs), _allLogs, true];
|
2016-07-15 10:23:47 +00:00
|
|
|
};
|