Add synchronizedObjects vehicle support to assignObjectsInList with an optional parameter

This commit is contained in:
jonpas 2015-09-28 16:17:12 +02:00
parent db2572acfd
commit 4521df0a57
2 changed files with 10 additions and 4 deletions

View File

@ -8,6 +8,7 @@
* 1: Variable Name <STRING>
* 2: Value <ANY>
* 3: Global <BOOL>
* 4: Vehicle <BOOL> (default: false)
*
* Return Value:
* None
@ -19,7 +20,7 @@
*/
#include "script_component.hpp"
params ["_list", "_variable", "_setting", "_global"];
params ["_list", "_variable", "_setting", "_global", ["_vehicle", false]];
if (typeName _list == "STRING") then {
_list = [_list, true, true] call FUNC(parseList);
@ -30,8 +31,13 @@ if (typeName _list == "STRING") then {
if (!isNil "_x") then {
if (typeName _x == typeName objNull) then {
if (local _x) then {
_x setVariable [_variable, _setting, _global];
TRACE_4("Set variable",_x,_variable,_setting,_global);
if (_vehicle) then {
(vehicle _x) setVariable [_variable, _setting, _global];
TRACE_6("Set variable vehicle",_x,vehicle _x,typeOf (vehicle _x),_variable,_setting,_global);
} else {
_x setVariable [_variable, _setting, _global];
TRACE_5("Set variable",_x,typeOf _x,_variable,_setting,_global);
};
};
};
};

View File

@ -22,5 +22,5 @@ if (!isNull _logic) then {
_setting = _logic getVariable ["enabled", 0];
[_list, QGVAR(medicClass), _setting, true] call EFUNC(common,assignObjectsInList);
[synchronizedObjects _logic, QGVAR(medicClass), _setting, true] call EFUNC(common,assignObjectsInList);
[synchronizedObjects _logic, QGVAR(medicClass), _setting, true, true] call EFUNC(common,assignObjectsInList);
};