08.04.2011, 21:48
hi,
i use a timer to check how many players are still in game.
If a player dies he is out of the game and he cant spawn anymore.
But this code does not work.
The first time the timer checks it ends the round even if there are still more than 1 players in game.
wheres the error?
regards...
i use a timer to check how many players are still in game.
If a player dies he is out of the game and he cant spawn anymore.
But this code does not work.
The first time the timer checks it ends the round even if there are still more than 1 players in game.
wheres the error?
pawn Код:
new pLiving;
new pAliveTimerKill;
new chainsawed[MAX_PLAYERS];
//Before round starts
chainsawed[playerid] = 0;//player is not dead yet...
//OnPlayerConnect
chainsawed[playerid] = 1;//so the player cant spawn while a round is in progress
//OnPlayerDeath
chainsawed[playerid] = 1;
//As soon as the round starts
pAliveTimerKill = SetTimer("pAliveChecker",4000,true);
forward pAliveChecker();//this is a timer checking how many players are still alive...
public pAliveChecker()
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if((chainsawed[i] == 0))//if player is still in game
{
pLiving++;
}
if(pLiving > 1)//if there are more than 1 players alive
{
pLiving = -1;//reset the variable
}
if(pLiving == 1 || pLiving == 0)//if only 1 player is alive or if server is empty
{
ChainsawEnder();//this is a stock that ends the round and changes the map...
KillTimer(pAliveTimerKill);
break;
}
}
return 1;
}
regards...