Ok found a solution after multiple attemps, here an array of struct that holds the player information:
#SET A STRUCT
PlayerInfoStruct<public>:=struct:
playerIndex:int=0
playerTeam:?team = false
Here the class
OnPlayerStart:=class(creative_device):
#====================VARIABLE DECLARATION================
var PlayerInfoStrucArray<public>:[]PlayerInfoStruct=array{} #PlayerIndex, PlayerTeam
OnBegin<override>()<suspends> : void =
TeamBalanceAsymmetric():void=
#//==Balancing Teams Asymmetrically
TeamBalanceAsymmetric():void=
Print("Beginning to balance teams")
FortTeamCollection := GetPlayspace().GetTeamCollection()
Print("AllPlayers Length is {AllPlayers.Length}")
for (TeamPlayer : AllPlayers):
var TeamToAssign:?team = false
set TeamToAssign = FindTeamWithLargestDifference()
if (AssignedTeam := TeamToAssign?, FortTeamCollection.AddToTeam[TeamPlayer, AssignedTeam]):
Print("Assigned player to a new team")
#Find the player index and store it in the struc
for(PlayerIndex -> PlayerType : AllPlayers): # Do for loop For all the Player
if(PlayerTemp :player = AllPlayers[PlayerIndex]):
PlayerInfoStructTemp:=PlayerInfoStruct{playerIndex:=PlayerIndex, playerTeam:=TeamToAssign}