Skip to content

UserInfo (engine.GetClientConsoleVariableValue) isn't initially networked. #33

@luttje

Description

@luttje

This workaround will network updates to UserInfo, but only if it changes after being initially set.

void Engine_PlayerAllowNewUserInfo( CBasePlayer *pPlayer, const char *userInfoName )
{
unsigned short index = connectedClients.Find( pPlayer->GetUserID() );
if ( index == connectedClients.InvalidIndex() )
{
DevWarning( "No client connect object found for player.\n" );
return;
}
ClientWithNetChannel info = connectedClients.Element( index );
KeyValues *conVars = GET_MEMORY_PTR( info.client, s_OffsetConVars, KeyValues );
if ( conVars->GetString( userInfoName, nullptr ) == nullptr )
{
conVars->SetString( userInfoName, "" );
}
}

We need to somehow signal the client to quickly change and then reset that userinfo, otherwise it won't be networked...

] lua_run print(player.GetByID(1):GetInfo("dynamite_model"))
<nothing>
] dynamite_model "models/dav0r/tnt/tnt.mdl" // Setting to the same value doesn't cause it to be networked
] lua_run print(player.GetByID(1):GetInfo("dynamite_model"))
<nothing>
] dynamite_model "something else"
] lua_run print(player.GetByID(1):GetInfo("dynamite_model"))
something else

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions