Team-balancer [Help] - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Team-balancer [Help] (
/showthread.php?tid=130547)
Team-balancer [Help] -
LudwigZ - 27.02.2010
Hello everyone
Can someone help me around Team balancer?
I know this topic isn't much long, Can someone tell me a tutorial how to set the balancer?
I would be very thankful
thx
Re: Team-balancer [Help] -
Eazy_Efolife - 27.02.2010
Код:
#define TEAM_1 1
#define TEAM_2 2
new Team1 = 0;
new Team2 = 0;
public OnGameModeInit()
{
AddPlayerClass(...); // Team 1
AddPlayerClass(...); // Team 2
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
if(classid == 0) { SetPlayerTeam(playerid, TEAM_1); }
else if(classid == 1) { SetPlayerTeam(playerid, TEAM_2); }
return 1;
}
public OnPlayerSpawn(playerid)
{
if(GetPlayerTeam(playerid) == TEAM_1)
{
Team1 ++;
}
else if(GetPlayerTeam(playerid) == TEAM_1)
{
Team2 ++;
}
}
public OnPlayerRequestSpawn(playerid)
{
if(TEAM_1 > TEAM_2 +1)
{
SendClientMessage(playerid, 0x000000, "Team is full, choose the other");
return 1;
}
elseif(TEAM_1 > TEAM_2 +1)
{
SendClientMessage(playerid, 0x000000, "Team is full, choose the other");
return 1;
}
return 1;
}
I just made this on the spot, so it's not tested yet.