GetLocalPlayer: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(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...")
 
No edit summary
Line 1: Line 1:
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,
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
to do his open util.cpp and find
<source>
<source>

Revision as of 13:04, 12 January 2016

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 );
}