Where do you use
OnMapStart function? Let me explain you.
EvenTeams needs a player's id in order to work.
If
OnMapStart uses a player's id, then you need to assign it to the timer. For example, it would be:
pawn Код:
SetTimerEx("RandomZombie",5000,false, "i", playerid); // an example
// somewhere else
public RandomZombie(playerid) return EvenTeams(playerid);
That would work, if
OnMapStart uses player's ID.
On the other hand, if this function is in OnGameModeInit for example or somewhere else, you will need to use a random ID.
But..
if you don't want this line:
Then it can be used like:
pawn Код:
stock EvenTeams()
{
new Humans, Zombies, rand = random(2);
if(rand == 0) // Setting ID 0 to Human and continuing with the cycle
{
foreach(Player, i)
{
if(Humans == Zombies)
{
HumanSetup2(i);
Humans ++;
}
}
}
else // Setting ID 0 to Zombie and continuing with the cycle
{
foreach(Player, i)
{
if(Humans == Zombies)
{
ZombieSetup2(i);
Zombies ++;
}
else
{
HumanSetup2(i);
Humans ++;
}
}
}
return 1;
}
// Somewhere else
public RandomZombie() return EvenTeams();
It's up to you.