09.08.2013, 10:11
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:
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:
It's up to you.
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);
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:
pawn Код:
ZombieSetup2(playerid);
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();