effectiveCommander – Talk
Categories: 
No edit summary  | 
				No edit summary  | 
				||
| Line 1: | Line 1: | ||
This command doesn't return the effective commander immediately. when this unit dies, it takes few second to make change.  | This command doesn't return the effective commander immediately. when this unit dies, it takes few second to make change.  | ||
on the other hand, the following script, runs slower (~ 0.  | on the other hand, the following script, runs slower (~ 0.01 ms) but will return the effective commander immediately:  | ||
  where ''vehicle'' is the same object as for effectiveCommander ''vehicle''    | |||
<code>  | |||
''vehicle'' call {  | ''vehicle'' call {  | ||
   if (!(typeof _this isKindOf "air")) exitWith {    |    if (!(typeof _this isKindOf "air")) exitWith {    | ||
| Line 12: | Line 13: | ||
_commandingUnit  | _commandingUnit  | ||
  };  |   };  | ||
</code>  | |||
Revision as of 05:29, 11 April 2016
This command doesn't return the effective commander immediately. when this unit dies, it takes few second to make change. on the other hand, the following script, runs slower (~ 0.01 ms) but will return the effective commander immediately:
where vehicle is the same object as for effectiveCommander vehicle
vehicle call {
 if (!(typeof _this isKindOf "air")) exitWith { 
   call {
     if (alive commander _this) exitWith {_commandingUnit = commander _this};
     if (alive gunner _this) exitWith {_commandingUnit = gunner _this};
      _commandingUnit = driver _this};
   };
   _commandingUnit = driver _this;
_commandingUnit
};