ClientCommand: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 40: | Line 40: | ||
</source> | </source> | ||
[[Category: | [[Category:Programming]] | ||
Revision as of 19:27, 15 April 2011
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" );
}
}