Quote:
Originally Posted by Freddo [BINMAN
]
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.
|
It's compiling fine, now I want to display AliveCount in a Textdraw, but it isn'T working =S
pawn Код:
format(string, sizeof(string), "Players Alive: %s", AliveCount);
TextDrawSetString(Textdraw0, string);
TextDrawShowForAll(Text:Textdraw0);