1)
PHP Code:
getDeadPlayers()
{
players = getentarray("player", "classname");
tmp = [];
for (i=0; i<players.size; i++)
{
if (players[i].pers["team"] == "axis" || players[i].pers["team"] == "allies")
if (players[i].sessionstate != "playing")
tmp[tmp.size] = players[i];
}
return tmp;
}
// in your function you write:
if (getDeadPlayers().size == 1)
iprintlnbold("only one zombie roaming!");
2)
When a player dies, DON'T respawn any player. The respawn-logic needs to be handled by a gametype-thread, which is an endless loop.
The loop is like:
PHP Code:
getAliveHunters()
{
players = getentarray("player", "classname");
tmp = [];
for (i=0; i<players.size; i++)
{
if (players[i].pers["team"] == "allies")
if (players[i].sessionstate == "playing")
tmp[tmp.size] = players[i];
}
return tmp;
}
while (1)
{
wait 0.05;
if (getAliveHunters().size == 0)
{
iprintlnbold("all hunters died, round restart... or server is just empty ;D");
newZombie = level.lastKilled; // set that always in playerkilled-callback
// iterate over player now and respawn them as axis or allies... work for you!
}
}
You can also set game["state"] == "roundrestart" etc. to handle new connected players e.g., but I just want you to understand the basic idea. Now you should be able to work the rest out.