Added: Monitor 5sec interval to propegate assignedTeams from leader, allowing team colors to be assigned by the team leader and show in the group. Uses vanilla team assignment. Closes #1279

This commit is contained in:
jaynus 2015-05-18 08:31:29 -07:00
parent 3c5eac96ea
commit d8b4b53b80

View File

@ -22,6 +22,41 @@ GVAR(ShowNamesTime) = -10;
{false},
[29, [false, false, false]], false] call cba_fnc_addKeybind; //LeftControl Key
// Monitor the assigned teams, and propegate them appropriately for the player
// This allows for assigned team colors to match across the entire group
[{
private["_leader", "_playerIsLeader", "_unitTeam"];
if (alive ACE_player) then {
_leader = leader (group ACE_player);
_playerIsLeader = false;
if(alive _leader) then {
if(_leader == ACE_player) then {
_playerIsLeader = true;
};
};
if (_playerIsLeader) then {
{
if(alive _x) then {
_unitTeam = _x getVariable [QGVAR(teamAssignment),"MAIN"];
if (_unitTeam != assignedTeam _x) then {
_x setVariable [QGVAR(teamAssignment), assignedTeam _x,true];
};
};
} forEach units (group ACE_player);
} else {
{
if(alive _x) then {
_unitTeam = _x getVariable [QGVAR(teamAssignment),"MAIN"];
if (_unitTeam != assignedTeam _x) then {
_x assignTeam _unitTeam;
};
};
} forEach units (group ACE_player);
};
};
}, 5, []] call CBA_fnc_addPerFrameHandler;
// Draw handle
addMissionEventHandler ["Draw3D", {_this call FUNC(onDraw3d);}];