ClientCommand

From Valve Developer Community
Revision as of 02:23, 16 April 2011 by Zeta (talk | contribs) (Created page with '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: <source lan…')

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, 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" );
	}
}