This is a multi-part message in MIME format. -- It's not safe for you to touch anything in an edict_t except for entvars (usually accessed via CBaseEntity->pev).
Here are the functions that Phineas Bot uses to count players. Apologies for what e-mail might do to formatting: int UTIL_ClientsInGame( void ) { int iCount = 0; for ( int iIndex = 1; iIndex <= gpGlobals->maxClients; iIndex++ ) { CBaseEntity * pPlayer = UTIL_PlayerByIndex( iIndex ); if ( pPlayer == NULL ) continue; if ( FNullEnt( pPlayer->pev ) ) continue; if ( FStrEq( STRING( pPlayer->pev->netname ), "" ) ) continue; iCount++; } return iCount; } int UTIL_HumansInGame( void ) { int iCount = 0; for ( int iIndex = 1; iIndex <= gpGlobals->maxClients; iIndex++ ) { CBaseEntity *pPlayer = UTIL_PlayerByIndex( iIndex ); if ( pPlayer == NULL ) continue; if ( FNullEnt( pPlayer->pev ) ) continue; if ( FStrEq( STRING( pPlayer->pev->netname ), "" ) ) continue; if ( FBitSet( pPlayer->pev->flags, FL_FAKECLIENT ) ) continue; iCount++; } return iCount; } > -----Original Message----- > From: Paul Samways [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, April 02, 2002 10:05 AM > To: [EMAIL PROTECTED] > Subject: [hlcoders] Counting players > > > I assumed this would be easy but our inclusion of bots has > left this in a > bit of a mess. > > I was just using the CountPlayers function in the multiplay > gamerules and > noticed that when I kick a bot it's still counted as a player. > > ie. > > I'm on the server alone, players == 1, > I add a bot, players == 2, > I kick the bot, players still == 2 > > Now the bot's not listed any more and the server doesn't > count it in it's > player count, all that stuff is fine, just this isn't. > > Now I presume I can just set edict->free to true when a bot > disconnects to > rectify this (as UTIL_PlayerByIndex will ignore it then), but > I don't want > to just do that without knowing if that's going to have more far flung > implications. Is this safe to do? -- [ winmail.dat of type application/ms-tnef deleted ] -- _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders