team balance
#1

Hi I would like to do team balance like 5 players per team.

I tried several times but still can spawn.
Reply
#2

You want to distribute each player on every spawn?
Reply
#3

Listen I want every team to handle only 5 players so when someone is trying to join it will send him a message.

"Team is full please choose another one"
Reply
#4

When a player spawns, distribute them on each team. Create a variable that determines the last team that was used to add a member onto it. Then if the variable reaches the last team set it back to the first one.

Define the maximum players allowed in a team.
pawn Код:
#define MAX_TEAM_COUNT 5
Then create a code wherein it'll prohibit the player from spawning if all the teams already have 5 members.
Reply
#5

so I put that code on top of the script? near color defines?
Reply
#6

I didn't know what you want until you replied on the other post.

Try this:
pawn Код:
#define MAX_TEAM_COUNT 5
// maximum members a team can have
#define MAX_TEAMS 10
// you can change this to the amount of teams you have

// declare an enumeration for each team having a variable for their member count.
enum TeamInfo
{
    TeamMembers,
};
// create variables for a player
new Team[MAX_TEAMS][TeamInfo];
new ChosenTeam[MAX_PLAYERS];

// when a player connects, their default team is set to -1 which is non-existent.
public OnPlayerConnect(playerid)
{
    ChosenTeam[playerid] = -1;
    return 1;
}

// after choosing their team, however you do it and is about to spawn it will check the number of members
// that the team already has.
public OnPlayerSpawn(playerid)
{
    if(ChosenTeam[playerid] != -1)
    {
        if(TeamMembers[ChosenTeam[playerid]] < MAX_TEAM_COUNT) // checks if the team members' count is less than the max(5)
        {
            SpawnPlayer(playerid); // spawns the player
            SetPlayerTeam(playerid, ChosenTeam[playerid]); // setting the players team to what they have selected.
            Team[ChosenTeam[playerid]][TeamMembers]++; // this will add 1 to the current team member count.
        }
        else SendClientMessage(playerid, -1, "The team you have chosen is already full.");
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by Skribblez
Посмотреть сообщение
I didn't know what you want until you replied on the other post.

Try this:
pawn Код:
#define MAX_TEAM_COUNT 5
// maximum members a team can have
#define MAX_TEAMS 10
// you can change this to the amount of teams you have

// declare an enumeration for each team having a variable for their member count.
enum TeamInfo
{
    TeamMembers,
};
// create variables for a player
new Team[MAX_TEAMS][TeamInfo];
new ChosenTeam[MAX_PLAYERS];

// when a player connects, their default team is set to -1 which is non-existent.
public OnPlayerConnect(playerid)
{
    ChosenTeam[playerid] = -1;
    return 1;
}

// after choosing their team, however you do it and is about to spawn it will check the number of members
// that the team already has.
public OnPlayerSpawn(playerid)
{
    if(ChosenTeam[playerid] != -1)
    {
        if(TeamMembers[ChosenTeam[playerid]] < MAX_TEAM_COUNT) // checks if the team members' count is less than the max(5)
        {
            SpawnPlayer(playerid); // spawns the player
            SetPlayerTeam(playerid, ChosenTeam[playerid]); // setting the players team to what they have selected.
            Team[ChosenTeam[playerid]][TeamMembers]++; // this will add 1 to the current team member count.
        }
        else SendClientMessage(playerid, -1, "The team you have chosen is already full.");
    }
    return 1;
}
still cant work. nvm
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)