From f511de0a4921427e1f1cc62f205139439bd545a7 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 14 May 2015 22:16:44 -0500 Subject: [PATCH] Calculate vitals interval on first run --- addons/medical/functions/fnc_handleUnitVitals.sqf | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/medical/functions/fnc_handleUnitVitals.sqf b/addons/medical/functions/fnc_handleUnitVitals.sqf index ebfb8be746..321f6dbd62 100644 --- a/addons/medical/functions/fnc_handleUnitVitals.sqf +++ b/addons/medical/functions/fnc_handleUnitVitals.sqf @@ -13,12 +13,15 @@ #include "script_component.hpp" -private ["_unit", "_heartRate","_bloodPressure","_bloodVolume","_painStatus", "_lastTimeValuesSynced", "_syncValues", "_airwayStatus", "_blood", "_bloodPressureH", "_bloodPressureL", "_interval"]; +private ["_unit", "_heartRate","_bloodPressure","_bloodVolume","_painStatus", "_lastTimeValuesSynced", "_syncValues", "_airwayStatus", "_blood", "_bloodPressureH", "_bloodPressureL", "_interval", "_lastMomentVitalsHandled"]; _unit = _this select 0; -_interval = time - (_unit getVariable [QGVAR(lastMomentVitalsHandled), 0]); +_lastMomentVitalsHandled = _unit getVariable [QGVAR(lastMomentVitalsHandled), -1]; _unit setVariable [QGVAR(lastMomentVitalsHandled), time]; +//If QGVAR(lastMomentVitalsHandled) is undefined then assume 1 second interval: +_interval = if (_lastMomentVitalsHandled == -1) then {1} else {time - _lastMomentVitalsHandled}; + if (_interval == 0) exitWith {}; _lastTimeValuesSynced = _unit getvariable [QGVAR(lastMomentValuesSynced), 0];