Something simple is looping through all the players in the level and in each loop assign a team, then switch a flag, and go to the next.
PHP Code:
function AssignTeams() {
team = 1;
for (player object : players in the level) {
player guild = team;
team = (team==1 ? 2 : 1); //(arg ? true : false)
}
}