22.09.2012, 12:58
I dont think that your code will work, it will only allow you to join the team with the lowest team members
pawn Код:
// global
enum Team {
BlueberryArmy,
MontgomeryArmy,
DillimoreArmy
}
stock
Team: gTeam[MAX_PLAYERS] = {Team, ...}
;
pawn Код:
// OnPlayerRequestClass
switch(classid) {
case 0..2: gTeam[playerid] = BlueberryArmy;
case 3..5: gTeam[playerid] = MontgomeryArmy;
case 6..8: gTeam[playerid] = DillimoreArmy;
}
pawn Код:
// OnPlayerRequestSpawn
new
i,
tie,
Team: biggest,
count[Team + Team: 1]
;
for( ; i != MAX_PLAYERS; ++i) { // foreach
count[gTeam[i]]++;
}
for(i = 1; i < _: Team; ++i) {
if((tie = count[biggest] / count[Team: i]) == 0) {
biggest = Team: i;
} else {
tie = (count[biggest] == count[Team: i]);
}
}
if((tie == 0) && (gTeam[playerid] == biggest)) {
return !SendClientMessage(playerid, 0xFF0000FF, "[ERROR] Team full. Choose another team!");
}
return true;
pawn Код:
// OnPlayerDisconnect
gTeam[playerid] = Team;

