Posts: 160
Threads: 23
Joined: Sep 2008
Reputation:
0
variables.
new PlayerAlive[MAX_PLAYERS];
OnPlayerSpawn
PlayerAlive = 1
OnPlayerDeath
PlayerAlive = 0
if( (PlayerAlive) = 1){
// player's alive)
}else{
// Player's dead
Posts: 50
Threads: 14
Joined: Jan 2009
Reputation:
0
I think you got it worng, I want something which tells the total ammount of players a life, not if a player is alive or not .
Posts: 139
Threads: 42
Joined: Aug 2008
Reputation:
0
Im not 100% sure how it would go but
for in OnPlayerSpawn put "Alive[playerid] = 1;" and under it have a count for example "AliveCount++;" you will need to define the count thou.
And in OnPlayerDeath put "Alive[playerid] = 0;" and "AliveCount--;"
Now if you want it in a command to see how many are alive, this might help. I think.
format(string, sizeof(string), "~r~Players Alive ~n~~y~ $%d",AliveCount);
GameTextForPlayer(playerid, string, 5000, 1);
You will need to have a "new string;" at the top of your onplayercommandtext callback. As well as "AliveCount;"
Now that possibly might work. Dont quote me on it as its untested.
Posts: 6,129
Threads: 36
Joined: Jan 2009
pawn Код:
new AliveCount;
for( new i = 0; i < MAX_PLAYERS; i++ )
{
if( GetPlayerState( i ) != 7 )
{
AliveCount++;
}
}
Using ******' foreach function would be more efficient. You'll have to reset the variables value (AliveCount = 0
every time you want to re-run the code, otherwise it'll pile on to each count, resulting in an inaccurate result.
For example:
pawn Код:
new AliveCount;
if( ! strcmp( cmdtext, "/alivecount", true ) )
{
AliveCount = 0;
for( new i = 0; i < MAX_PLAYERS; i++ )
{
if( GetPlayerState( i ) != 7 )
{
AliveCount++;
}
}
}
The code above should be used under OnPlayerCommandText.
%s is for strings, use %d
Posts: 167
Threads: 0
Joined: Aug 2009
Reputation:
0
Where did you put the textdraw code?