01.08.2009, 10:09
I just learned this some time ago, it's called 'module division', I've got a big problem with maths so I can't really explain it to you good, but I give you an example which I use myself:
This would (if you had 50 players), make 25 people team 1 and the other 25 people team 2, if a new player would connect, you could do (make sure to set PlayerTeam[playerid] to 0 at (dis)connect) onplayerspawn:
No idea how to do it for 7 teams lol I'm too noob for that, but take a look at the wiki page, might make more sense to you then me:
http://en.wikipedia.org/wiki/Modulo_operation
pawn Код:
// on top
new PlayerTeam[MAX_PLAYERS];
new team;
// somewhere else:
for (new i = 0; i <MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i))
{
team = playerid % 2;
if(team == 0)
{
PlayerTeam[i] = 1;
}
if(team == 1)
{
PlayerTeam[i] = 2;
}
}
return 1;
}
pawn Код:
if(PlayerTeam[playerid] == 0)
{
team = playerid % 2;
if(team == 0)
{
PlayerTeam[i] = 1;
}
if(team == 1)
{
PlayerTeam[i] = 2;
}
}
http://en.wikipedia.org/wiki/Modulo_operation