I've seen this come up a lot in several places. I suppose if it's indexed here someone who needs it will eventually find it. The purpose of this tutorial is to efficiently and easily set up teams without writing several duplicate lines of code. First off, I'd like to answer that newbie question: No, there is no menu to set teams. It must be done in the trigger editor. That being said, lets begin.
This tutorial uses raw settings, so set this by pressing Ctrl+D.
Note: If you are familiar with triggering you may want to skip to the bottom and look at the full trigger.
Newbies Start Here
Open up the Trigger Editor Module [F6].
Create a New Trigger [Ctrl+T]
Lets create our event, click inside the pane on the right and either right-click -> New ->Event or press Ctrl+E. In the new popup menu, use the find feature and type "init" (without quotes) and it will bring up TriggerAddEventMapInit(), click to add this event.
Click inside the pane on the right again and insert a new variable [Ctrl+B or right-click -> New ->Variable]
Leave the type as integer, I named mine 'A'; this will be used to loop through all the players later.
Now lets create our player group variable, the player group is the actual 'team'. If you want everyone on the same team, then you only need one. If you want 3 teams then you need 3, etc. I will be demonstrating the creation of all players 1-13 against player 14 (A common scenario for most TD's and team games)
Again click on the right pane and insert the new variable [Ctrl+B or right-click -> New ->Variable].
Change the type to Player Group, and give it a name (don't worry about any other fields as they will be defined in our trigger).
Now for the fun part, triggering.
Using the find feature this should be a breeze. The find feature is located in the top right of the Trigger Editor Module.
Search for "For Each" it will bring up a few options, we want the one dealing with integers (it is the fifth option from the top)
Now at the bottom of the right pane it will read "ForEachInteger(var, 1, 10, 1)"
Click var and select our integer A. Click the 10 and change it to 13.
We just created a loop counting from 1 to 13 by 1's.
Now we want an If - then statement to determine whether a player is active or not. No point in putting inactive players into our teams right?
Create a new action and type "if then" it will bring up General - If (Conditions) then do (Actions) else do (Actions). Select it.
Now under our if then we want to set up our condition.
Right click again, new -> Condition (or ctrl+k)
Use the default selection "Comparison"
Your second pane will look like this now:
Click UnitGetOwner and use the find box. Search for 'status' and select PlayerStatus. You now have
Next we want to define the player, click the 1. Change this to our loop variable A.
Now click Val2. Select the source radio button "Preset" and Playing.
Our trigger now checks to see if players 1-13 are playing or not, if you start now however, nothing will happen.
Under actions we need to set up our force now.
Create a new action under 'Then' of our If - Then statement.
Find 'Add Player' the first option is what we want, PlayerGroupAdd.
It will show: PlayerGroupAdd(g, 1)
Click the g and change it to our integer variable A.
Now click the 1 and change it to our player group Team.
You've now added players 1-14 to player group Team. But just because they are in the same player group doesn't make them allies. There is one more step.
Create another action (be sure not to put it under the else tab of our if - then statement).
In the find box, type "allia" and it will bring up some options. We want the first one SetPlayerGroupAlliance.
Select it and it will look like this:
Now click players and change this to our player group Team.
That's it, exit out of raw data mode by pressing Ctrl+D again and check your work with the triggers shown below.
I attached a screenshot of the initialization of 2 teams of 2 players each (1&2 vs 3&4), done in a simple way... if you have minimum intuition or practice with the trigger editor, it will be easy. Just remember that "find" is your friend ;)
(I suggest using the "Ally With Shared Vision" setting, mine is "Ally" because i don't want allies share vision in the map i used this trigger)
Why are you bothering with the whole "if player is playing, then add him to the team" instead of simply adding the player to the team regardless of whether he is playing. Is there a downside of adding a nonplaying player to an alliance? Or is there an upside of not adding a nonplaying player to an alliance?