ACE3/addons/common/functions/fnc_setDefinedVariable.sqf

33 lines
641 B
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
2015-09-19 18:34:07 +00:00
/*
* Author: Glowbal
* setVariable value
2015-01-16 23:21:47 +00:00
*
2015-09-19 18:34:07 +00:00
* Arguments:
* 0: Unit <OBJECT>
* 1: variableName <STRING>
* 2: value <ANY>
*
* Return Value:
* None
*
* Example:
* [bob, "var", 5] call ace_common_fnc_setDefinedVariable
*
2015-09-19 18:34:07 +00:00
* Public: Yes
2015-01-16 23:21:47 +00:00
*/
2015-09-19 18:34:07 +00:00
params ["_unit", "_variable", "_value", "_global"];
2015-05-14 18:06:06 +00:00
2015-09-19 18:34:07 +00:00
if (isNil "_global") then {
private _definedVariable = [_variable] call FUNC(getDefinedVariableInfo);
2015-05-14 18:06:06 +00:00
2015-09-19 18:34:07 +00:00
_definedVariable params ["", "", ["_global", false]];
2015-01-16 23:21:47 +00:00
};
2015-11-30 16:14:05 +00:00
if (!isNil "_value") exitWith {
2015-09-19 18:34:07 +00:00
_unit setVariable [_variable, _value, _global];
2015-01-16 23:21:47 +00:00
};
2015-09-19 18:34:07 +00:00
_unit setVariable [_variable, nil, _global];