team balance - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: team balance (
/showthread.php?tid=335272)
team balance -
oscar7610 - 17.04.2012
Hi I would like to do team balance like 5 players per team.
I tried several times but still can spawn.
Re: team balance -
ViniBorn - 17.04.2012
You want to distribute each player on every spawn?
Re: team balance -
oscar7610 - 17.04.2012
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"
Re: team balance -
Skribblez - 17.04.2012
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.
Then create a code wherein it'll prohibit the player from spawning if all the teams already have 5 members.
Re: team balance -
oscar7610 - 17.04.2012
so I put that code on top of the script? near color defines?
Re: team balance -
Skribblez - 17.04.2012
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;
}
Re: team balance -
oscar7610 - 17.04.2012
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