Salut,
sinon tu peut t'inspirer de celui qu'a fait Y_Less:
#define MAX_TEAMS (27) // Up to 27 teams (for example)
#define GET_PLAYER_TEAM(%0) gTeam[(%0)]
//#define GET_PLAYER_TEAM(%0) GetPlayerTeam(%0)
#define SET_PLAYER_TEAM(%0,%1) gTeam[(%0)] = (%1)
//#define SET_PLAYER_TEAM(%0,%1) SetPlayerTeam(%0, %1)
new
gTeamCount[MAX_TEAMS];
public OnPlayerConnect(playerid)
{
SET_PLAYER_TEAM(playerid, NO_TEAM);
}
public OnPlayerDisconnect(playerid, reason)
{
if (GET_PLAYER_TEAM(playerid) != NO_TEAM)
{
gTeamCount[GET_PLAYER_TEAM(playerid)]--;
}
}
SetPlayerTeamBalanced(playerid)
{
if (GET_PLAYER_TEAM(playerid) != NO_TEAM)
{
gTeamCount[GET_PLAYER_TEAM(playerid)]--;
}
new
tm = -1;
for (new i = 0, tc = cellmax; i < MAX_TEAMS; i++)
{
new
cur = gTeamCount[i];
if (cur)
{
if (cur < tc)
{
tc = cur;
tm = i;
}
}
else
{
// Team with no players on - put them on it (saves time)
SET_PLAYER_TEAM(playerid, i);
gTeamCount[i]++;
return i;
}
}
SET_PLAYER_TEAM(playerid, tm);
gTeamCount[tm]++;
return tm;
}
public OnPlayerRequestSpawn(playerid)
{
SetPlayerTeamBalanced(playerid);
return 1;
}
++Sim++