How can i check if all zombies dead? -
KillerDVX - 08.06.2015
I have 2 teams.
TEAM_SURVIVANTS
and
TEAM_ZOMBIES.
I wan't to create a checkpoint when all zombies dead.
But how could i check that.. ?

Help !
Re: How can i check if all zombies dead? -
SickAttack - 08.06.2015
Get the total amount of zombies once the game has started (save it in a variable), if a new zombie joins the game during the act, increase that amount by one. If one leaves, decrease it by one. If one dies, decrease it by one. And once there are no more zombies alive, create the checkpoint.
Or you could loop through all the players and check if there are any zombies left, and if the script finds at least one, stop the loop because the process doesn't need to continue as it will already return false because one zombie is alive.
This will require foreach, go get it if you do not have it yet:
pawn Код:
stock AreAllZombiesDead()
{
new bool:alive = false;
foreach(new i: Player)
{
if(pTeam[playerid] == TEAM_ZOMBIE)
{
alive = true;
break;
}
}
if(!alive) return true;
return false;
}
Re : How can i check if all zombies dead? -
KillerDVX - 08.06.2015
Now, if all zombies are dead, and i wanna to send to all players that they are dead,
What should i do?
Re: How can i check if all zombies dead? -
jamesbond007 - 09.06.2015
pawn Код:
if(AreAllZombiesDead())
{
SendClientMessageToAll(-1, "The zombies are all dead");
}
Re : How can i check if all zombies dead? -
KillerDVX - 09.06.2015
Under OnPlayerDeath or..?
Re : How can i check if all zombies dead? -
KillerDVX - 09.06.2015
Please Help ?
Re: How can i check if all zombies dead? -
JaydenJason - 09.06.2015
Make a global timer for that, or it can go under onplayerdeath
Re: How can i check if all zombies dead? -
DarkLouis - 09.06.2015
If you don't use foreach, you can do:
PHP код:
public Zombies()
{
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i)) continue;
new zombie;
if(pTeam[i] == TEAM_ZOMBIE))
{
zombie ++;
}
}
return zombie;
}
public OnPlayerDeath(playerid, killerid, reason)
{
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i)) continue;
if(!Zombies())
{
SendClientMessage(i, -1, "All zombies are dead!" )
}
}
return 1;
}
Re : How can i check if all zombies dead? -
KillerDVX - 09.06.2015
I use foreach
Re : How can i check if all zombies dead? -
KillerDVX - 09.06.2015
Help?