Quote:
Originally Posted by Brad
Don't use that method anyway, though it seems the most common sense way to do it.
Before I give you updated code, I have to question why the hell you'd be looping this. That's a bad idea and needless to boot. Do you want to know the current T count at any given moment?
This code will give you the T count:
Code:
new players[32], playerCnt, playerIdx, terroristCnt;
get_players(players, playerCnt);
for (playerIdx = 0; playerIdx < playerCnt; playerIdx++)
{
if (get_user_team(players[playerIdx]) == 2)
{
terroristCnt++;
}
}
You'll need to confirm if terrorists are team 1 or 2 as I can't recall at the moment.
|
You don't need to use both,get_players and a loop. Just use one of them.
PHP Code:
new iTRCount = 0
new iMaxPlayers = get_maxplayers()
for(new i=1;i <= iMaxPlayers;i++)
{
if(is_user_connected(i) && get_user_team(i) == 1)
iTRCount++
}