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