"Ally same colors" or something like that. So long as each team name has the same color, they will be considered the same team.
Then, when a player is spawned, check the number of their team. If it is 1, go to the equipment room for their class. If it is 2, go to a different one, etc.