View Single Post
Re: ClientDisconnect() is driving me NUTS!!!
Old
  (#8)
Cheeseh
[rcbot]
 
Cheeseh's Avatar
 
Status: Offline
Posts: 361
Join Date: Dec 2003
Location: China
Default Re: ClientDisconnect() is driving me NUTS!!! - 07-01-2004

btw PM, you can sort the problem you have by doing something like this if you want to get the number of clients playing.

getPlayerUserId will tell you if the player is in the server

but not if its joining, which is what I really need to know

:o hold on.. i think it returns 0 when a player is not in the server, maybe its -1 if connecting.. gonna check.
Code:
int UTIL_GetNumClients ( void )
{
	int i = 0;

	edict_t *pPlayer;
	int iNum;

	iNum = 0;

	for ( i = 1; i <= gpGlobals->maxClients; i ++ )
	{
		pPlayer = INDEXENT(i);

		if ( pPlayer == NULL )
			continue;
		if ( pPlayer->free )
			continue;

		if ( (*g_engfuncs.pfnGetPlayerUserId)(pPlayer) > 0 )
				iNum++;
	}

	return iNum;
}

Last edited by Cheeseh; 07-01-2004 at 18:28..
  
Reply With Quote