#define TERRORISTS 0
#define SWAT 1
new gTeam[MAX_PLAYERS];
You'll have to be a bit more specific. What do you define by team balancing?
|
I want that the equel amount on players and when a player requests the spawn for a team
|
//Globals new requestedTeam[MAX_PLAYERS]; //OnPlayerRequestClass requestedTeam[playerid] = classid; //OnPlayerRequestSpawn new teamTerroristsPlayers, teamSwatPlayers; for(new otherplayerid = 0, playerCount = GetPlayerPoolSize(); otherplayerid <= playerCount; otherplayerid++) { if(gTeam[otherplayerid] == TERRORISTS) { teamTerroristsPlayers++; } else { teamSwatPlayers++; } } //If there are less terrorists than swat players and the player chose the swat class //OR if there are less swat than terrorists players and the player chose the terrorists class if((teamTerroristsPlayers < teamSwatPlayers && requestedTeam[playerid] == USE_SWAT_CLASS_HERE) || (teamSwatPlayers < teamTerroristsPlayers && requestedTeam[playerid] == USE_TERRORISTS_CLASS_HERE)) { return 0; //Don't let the player spawn } //If there are less terrorists than swat players and the player chose the terrorists class //OR if there are less swat than terrorists players and the player chose the swat class //OR if the amount of terrorists players is equal to the amount of swat players, regardless of the chosen class else { if(requestedTeam[playerid] == USE_TERRORISTS_CLASS_HERE) { gTeam[playerid] = TERRORISTS; } else { gTeam[playerid] = SWAT; } return 1; //Let the player spawn }
//OnPlayerRequestClass new teamTerroristsPlayers, teamSwatPlayers; for(new otherplayerid = 0, playerCount = GetPlayerPoolSize(); otherplayerid <= playerCount; otherplayerid++) { if(gTeam[otherplayerid] == TERRORISTS) { teamTerroristsPlayers++; } else { teamSwatPlayers++; } } if((teamTerroristsPlayers < teamSwatPlayers && classid == USE_SWAT_CLASS_HERE) || (teamSwatPlayers < teamTerroristsPlayers && classid == USE_TERRORISTS_CLASS_HERE)) { return 0; } else { if(classid == USE_TERRORISTS_CLASS_HERE) { gTeam[playerid] = TERRORISTS; } else { gTeam[playerid] = SWAT; } return 1; }