09.04.2010, 12:40
Take off of this example:
playerid - the player
team_1 - the team that is being calculated by the ratio
team_2 - the other team
ratio - the ratio of which to balance team 1 from team 2
teamvar - the variable to hold the player's team
EXAMPLE:
playerid - the player
team_1 - the team that is being calculated by the ratio
team_2 - the other team
ratio - the ratio of which to balance team 1 from team 2
teamvar - the variable to hold the player's team
EXAMPLE:
pawn Код:
OnPlayerSpawn(playerid)
{
TeamBalance(playerid, TEAM_GREEN, TEAM_BLUE, 1, Team); // Sets the balance of the teams equal
}
pawn Код:
TeamBalance(playerid, team_1, team_2, ratio, teamvar[]) {
new result_var = (Players() / ratio);
for(new x = 0; x < MAX_PLAYERS; x++) {
if(teamvar[x] == team_1) {
count++;
}
}
if(count < result_var) {
teamvar[playerid] = team_1;
} else {
teamvar[playerid] = team_2;
}
}