GetLocalPlayer: Difference between revisions
Jump to navigation
Jump to search
Msalinas2877 (talk | contribs) No edit summary |
Msalinas2877 (talk | contribs) 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 | to do this open util.cpp and find | ||
<source> | <source> | ||
CBasePlayer *UTIL_GetLocalPlayer( void ) | CBasePlayer *UTIL_GetLocalPlayer( void ) |
Revision as of 14:06, 5 August 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 this 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 );
}