22.10.2009, 18:44
i've been looking around on the forum for a team balancer, or a way to make one. is there a way to get the count of people in a team
Originally Posted by Tigerbeast11
I want this too, but I couldn't find anything...
|
new Team1;
new Team2;
new PlayerTeam[playerid];
if(Team1 < Team 2) //Checks if Team 1 has less players than team 2
{
Team1 += 1; //adds a player to the team
PlayerTeam[playerid] = 1;
return 1; //spawns the player
}
else
{
SendClientMessage(playerid,COLOR,"...");//Message telling the player the team wouldnt be balanced if they joined it.
return 0; // Makes it so the player dosen't spawn.
}
if(PlayerTeam[playerid] == 1)
{
Team1 -= 1;
}
else
{
Team2 -= 1;
}
new Text:RandomTeamJoin[][] = { {SetPlayerTeam(playerid,TEAM_BLUE)}, {SetPlayerTeam(playerid,TEAM_RED)} };
Originally Posted by ►Peter Corneile◄ [hugu-hosting.co.uk
]
Quote:
|
#define NUM_TEAMS (2)
#if defined NUM_TEAMS
#if NUM_TEAMS > 1
new T_Counter[NUM_TEAMS];
#endif
#endif
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
}