23.10.2009, 16:32
pawn Код:
#define NUM_TEAMS (2)
pawn Код:
#if defined NUM_TEAMS
#if NUM_TEAMS > 1
new T_Counter[NUM_TEAMS];
#endif
#endif
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
//other code you got
#if defined NUM_TEAMS
#if NUM_TEAMS > 1
#if !defined gTeam
#error Team Balancer: didnt found the example team variable, change it!
#endif
new bigger_teams;
for(new i; i < NUM_TEAMS; i++) if(T_Counter[i] > T_Counter[gTeam[playerid]]) bigger_teams++;
if(bigger_teams < (NUM_TEAMS / 2)) return false;
T_Counter[gTeam[playerid]]++;
#endif
#endif
//other code you got
}
1 Team, team balancer is deactivated :O (same when you comment NUM_TEAMS)
2 Teams, players can only join the weakest team
3 Teams, players can only join the weakest team
4 Teams, players can join the two weakest teams
5 Teams, players can join the two weakest teams
6 Teams, players can join the three weakest teams
... and so on ...