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