OLO 10 Posted December 1, 2012 Hello I have an array that consist of several units like: units_array = [unit1,unit2,unit3,unit4,unit5]; Each one of those units has speciffic variable set by using setVariable command. My question is how I can check (using getVariable command), which one of those units has that one variable I want? Share this post Link to post Share on other sites
OLO 10 Posted December 1, 2012 If so, then where's the problem here: if !(isNil {{_x getVariable "101"} forEach units_array}) then {myCar setPos (position _x)}; Share this post Link to post Share on other sites
samatra 85 Posted December 1, 2012 { if(!isNil(_x getVariable "101")) then { myCar setPos (getPos _x); }; } forEach units_array; Share this post Link to post Share on other sites
OLO 10 Posted December 1, 2012 There is one minor mistake with brackets in the upper code. Instead of '()' flanking getVariable command, there should be '{}', but it's good and now I have what I wanted. Propper code: { if(!isNil{_x getVariable "101"}) then { myCar setPos (getPos _x); }; } forEach units_array; Thanks for the answers. Problem solved. Share this post Link to post Share on other sites
cuel 25 Posted December 1, 2012 Alternatively use the getVariable array object getVariable [name, defaultValue] Parameters: object: Object or Location name: String - Variable name that was defined in setVariable (Case sensitive) defaultValue: Any Value - Value to return if variable doesn't exist Share this post Link to post Share on other sites