20.11.2010, 07:03
(
Последний раз редактировалось Kitten; 24.11.2013 в 05:26.
)
Solved
new zPlayers, hPlayers;
new NonZombieCount;
#define MIN_NONZOMBIES 3
foreach( Player, i )
{
if( PlayerTeam[i] != ZOMBIE_TEAM ) NonZombieCount++;
if( NonZombieCount >= MIN_NONZOMBIES ) break;
}
if( NonZombieCount >= MIN_NONZOMBIES )
{
new PlayersAssigned, pID;
do{
pID = Iter_Random(Player);
if( PlayerTeam[pID] == ZOMBIE_TEAM )
{
PlayerTeam[pID] = HUMAN_TEAM;
PlayersAssigned++;
}
}
while( PlayersAssigned >= MIN_NONZOMBIES );
}
#undef MIN_NONZOMBIES
new NonZombieCount;
foreach( Player, i )
{
if( PlayerTeam[i] != ZOMBIE_TEAM ) NonZombieCount++;
}
if( !NonZombieCount )
{
new PlayersAssigned, pID;
do{
pID = Iter_Random(Player);
if( PlayerTeam[pID] == ZOMBIE_TEAM )
{
PlayerTeam[pID] = HUMAN_TEAM;
PlayersAssigned++;
}
}
while( PlayersAssigned >= MIN_NONZOMBIES );
}
forward Human(playerid);
SetTimer("Human", 2000,1);
public Human(playerid)
{
if(gTeam[playerid] == TEAM_ZOMBIE)
{
// Register here if so many players in the team are to change it
gTeam[playerid] = TEAM_HUMAN;
return 1;
}
return 1;
}
Or just return 0 at OnPlayerRequest spawn when it appears that one team contains more players then the other, no need for stupido timers.
|