ClientCommand
Jump to navigation
Jump to search
ClientCommand() is how the server receives client commands sent using ServerCmd.
Using the below snippet of code as an example is how the server receives commands:
bool CSDKPlayer::ClientCommand( const CCommand &args )
{
...
else if ( FStrEq( pcmd, "menuopen" ) )
{
SetClassMenuOpen( true );
return true;
}
...
}
The command "menuopen" is called by engine->ServerCmd( "menuopen" ) of CSDKClassMenu::SetVisible (ie. this code is executed by the Client)
void CSDKClassMenu::SetVisible( bool state )
{
BaseClass::SetVisible( state );
if ( state )
{
engine->ServerCmd( "menuopen" ); // to the server
engine->ClientCmd( "_cl_classmenuopen 1" ); // for other panels
}
else
{
engine->ServerCmd( "menuclosed" );
engine->ClientCmd( "_cl_classmenuopen 0" );
}
}