Team balancer
#7

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;
Reply


Messages In This Thread
Team balancer - by newbienoob - 21.09.2012, 10:01
Re: Team balancer - by park4bmx - 21.09.2012, 12:45
Re: Team balancer - by newbienoob - 22.09.2012, 03:59
Re: Team balancer - by YourLord - 22.09.2012, 04:12
Re: Team balancer - by newbienoob - 22.09.2012, 07:07
Re: Team balancer - by Nexotronix - 22.09.2012, 08:24
AW: Re: Team balancer - by Nero_3D - 22.09.2012, 12:58
Re: AW: Re: Team balancer - by newbienoob - 23.09.2012, 14:03
AW: Re: AW: Re: Team balancer - by Nero_3D - 23.09.2012, 14:31
Re: Team balancer - by newbienoob - 23.09.2012, 14:47

Forum Jump:


Users browsing this thread: