2016-07-15 10:23:47 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Add an entry to the specified log
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The patient <OBJECT>
|
|
|
|
* 1: The log type <STRING>
|
|
|
|
* 2: The message <STRING>
|
|
|
|
* 3: The arguments for localization <ARRAY>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
2017-06-15 19:35:33 +00:00
|
|
|
* [bob, "type", "message", [_args]] call ACE_medical_treatment_fnc_addToLog
|
2017-06-08 13:31:51 +00:00
|
|
|
*
|
2016-07-15 10:23:47 +00:00
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
params ["_unit", "_type", "_message", "_arguments"];
|
|
|
|
|
|
|
|
if (!local _unit) exitWith {
|
|
|
|
[QGVAR(addToMedicalLog), _this, _unit] call CBA_fnc_targetEvent;
|
|
|
|
};
|
|
|
|
|
|
|
|
date params ["", "", "", "_hour", "_minute"];
|
|
|
|
|
2016-10-13 19:21:42 +00:00
|
|
|
private _moment = format [["%1:%2", "%1:0%2"] select (_minute < 10), _hour, _minute];
|
|
|
|
private _logVarName = format [QEGVAR(medical,logFile_%1), _type];
|
2016-07-15 10:23:47 +00:00
|
|
|
private _log = _unit getVariable [_logVarName, []];
|
2016-10-13 19:21:42 +00:00
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
if (count _log >= 8) then {
|
|
|
|
private _newLog = [];
|
2016-10-13 19:21:42 +00:00
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
{
|
|
|
|
// ensure the first element will not be added
|
|
|
|
if (_forEachIndex > 0) then {
|
|
|
|
_newLog pushBack _x;
|
|
|
|
};
|
|
|
|
} forEach _log;
|
2016-10-13 19:21:42 +00:00
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
_log = _newLog;
|
|
|
|
};
|
2016-10-13 19:21:42 +00:00
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
_log pushBack [_message, _moment, _type, _arguments];
|
|
|
|
|
|
|
|
_unit setVariable [_logVarName, _log, true];
|
|
|
|
["ace_medicalLogEntryAdded", [_unit, _type, _message, _arguments]] call CBA_fnc_localEvent;
|
|
|
|
|
|
|
|
private _logs = _unit getVariable [QEGVAR(medical,allLogs), []];
|
2016-10-13 19:21:42 +00:00
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
if !(_logVarName in _logs) then {
|
|
|
|
_logs pushBack _logVarName;
|
|
|
|
_unit setVariable [QEGVAR(medical,allLogs), _logs, true];
|
|
|
|
};
|