17.04.2012, 20:11
Hi I would like to do team balance like 5 players per team.
I tried several times but still can spawn.
I tried several times but still can spawn.
#define MAX_TEAM_COUNT 5
#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;
}
I didn't know what you want until you replied on the other post.
Try this: pawn Код:
|