Forum Jump :

Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 59
In-game name: Kobayashi Maru

 
#183601 Posted at 2015-10-29 00:03        
     
And, by the way, if you want a player to be leader anytime, at any place in the group !-)

//In SP with switchable units:
0= [] spawn {while {!isMultiplayer} do {
   private "_unit_sel";
   for "_i" from 0 to (count switchableUnits - 1) do {
      _unit_sel = (switchableUnits select _i);
     call {
        if (isplayer (_unit_sel) && alive (_unit_sel)) exitWith {
          if (_unit_sel getVariable ["switched_unit",false]) exitWith {};
          if (_unit_sel != leader (group _unit_sel)) then {(group _unit_sel) selectLeader _unit_sel; {_x dofollow _unit_sel} forEach units (group _unit_sel);
          _unit_sel setVariable ["switched_unit", true]};
          };
        if (alive _unit_sel && (_unit_sel getVariable ["switched_unit",false])) exitWith {  _unit_sel setVariable ["switched_unit", false]};
        _unit_sel setVariable ["switched_unit", false];
     };
   };
   sleep 2;
 };
};

// in MP, to be sure a player is leader of his group (AI inside), first JIP first served
if (!isServer) exitWith {};
if (!isPlayer leader (group player)) then {for "_i" from 0 to (count units (group player)) -1 do {
   if (isPlayer ((units group player) select _i)) exitwith {[(group player), (units group player) select _i] remoteExec ["selectLeader", groupOwner (group player)]}}};

See selectLeader on BIKI to uderstand this code;

This post was edited by Pierre MGI (2015-10-29 00:11, ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS





Tags: Group, Scripting, Talk