GetLocalPlayer

From Valve Developer Community
Revision as of 12:59, 12 January 2016 by Msalinas2877 (talk | contribs) (Created page with "In Multiplayer UTIL_GetLocalPlayer will return null, instead you can use UTIL_GetListenServerHost or you can use a simple fix that will get all players, to do his open util.cp...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In Multiplayer UTIL_GetLocalPlayer will return null, instead you can use UTIL_GetListenServerHost or you can use a simple fix that will get all players, to do his open util.cpp and find

CBasePlayer *UTIL_GetLocalPlayer( void )
{
	if ( gpGlobals->maxClients > 1 )
	{
		if ( developer.GetBool() )
		{
			Assert( !"UTIL_GetLocalPlayer" );
			
#ifdef	DEBUG
			Warning( "UTIL_GetLocalPlayer() called in multiplayer game.\n" );
#endif
		}

		return NULL;
	}

	return UTIL_PlayerByIndex( 1 );
}

and replace it for this

CBasePlayer *UTIL_GetLocalPlayer( void )
{
	if ( gpGlobals->maxClients > 1 )
	{
		for (int i = 1; i <= gpGlobals->maxClients; i++)
		{
			return UTIL_PlayerByIndex(i);
		}
	}

	return UTIL_PlayerByIndex( 1 );
}