team balancer
#1

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
Reply
#2

I read the same post 2-3 days before (was it by you ?)
Reply
#3

nope, i got started with this today, so dont think so
Reply
#4

I want this too, but I couldn't find anything...
Reply
#5

Quote:
Originally Posted by Tigerbeast11
I want this too, but I couldn't find anything...
So you were the one who asked this before eh ?
Reply
#6

pawn Код:
new Team1;
new Team2;
new PlayerTeam[playerid];
When a player tries to join team 1:
pawn Код:
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.
}
Do the same for team 2.

On Disconnect:
pawn Код:
if(PlayerTeam[playerid] == 1)
{
Team1 -= 1;
}
else
{
Team2 -= 1;
}

UNTESTED. Should work, I think you get the point
Reply
#7

hmm, i think i already got something, but i also need a function to random set a team. i tryed this, but it wont work:
Код:
new Text:RandomTeamJoin[][] = {
{SetPlayerTeam(playerid,TEAM_BLUE)},
{SetPlayerTeam(playerid,TEAM_RED)}
};
no error, but my pawno gets crazy of it.
Reply
#8

Quote:
Originally Posted by ►Peter Corneile◄ [hugu-hosting.co.uk
]
Quote:
Originally Posted by Tigerbeast11
I want this too, but I couldn't find anything...
So you were the one who asked this before eh ?
certainly not!
Reply
#9

ՅՄʍρ
Reply
#10

pawn Код:
#define NUM_TEAMS (2)
pawn Код:
#if defined NUM_TEAMS
    #if NUM_TEAMS > 1
        new T_Counter[NUM_TEAMS];
    #endif
#endif
pawn Код:
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
}
Examples

1 Team, team balancer is deactivated :O (same when you comment NUM_TEAMS)
2 Teams, players can only join the weakest team
3 Teams, players can only join the weakest team
4 Teams, players can join the two weakest teams
5 Teams, players can join the two weakest teams
6 Teams, players can join the three weakest teams
... and so on ...
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)