another way would be to catch "TeamInfo" messages..
except they are unreliable because the time they are sent is when someone joins but when that someone barely joins he has no team and it won't send another TeamInfo message until the next time someone joins..
each time someone joins it gets sent for all the players to refresh their team or something..
this is statsme's implementation of catching these messages.. from v2.7 but also used in v2.8
PHP Code:
// team is changed then this msg is send
void Client_TeamInfo_CS(void* mValue)
{
if (mPlayer) return;
static int index;
switch (mState++) {
case 0:
index = *(int*)mValue;
break;
case 1:
const char* team = (char*)mValue;
int i;
for(i = 0; i < sm.team_num ; ++i)
if ( !strcmpi(sm.team_name[i],team) )
break;
//accept only new teams, max. 4 teams
if ( i == sm.team_num && i < 4 )
strcpy( sm.team_name[sm.team_num++], team);
player_t*pPlayer = GET_PLAYER_POINTER_I( index );
if ( !pPlayer->ingame ) {//this is bot...
edict_t* pEntity = INDEXENT(index);
PlayerConnect( pEntity , STRING(pEntity->v.netname), "127.0.0.1:27005" );
PlayerPutInServer( pPlayer );
}
strcpy(pPlayer->team_name, sm.team_name[i]); //save name of team
pPlayer->team_index = i;
sm.team_players[0] = 0;
sm.team_players[1] = 0;
sm.team_players[2] = 0;
sm.team_players[3] = 0;
for ( i = 1; i <= gpGlobals->maxClients; ++i )
{
pPlayer = GET_PLAYER_POINTER_I( i );
sm.team_players[pPlayer->team_index]++;
}
}
}