ClientCommand: Difference between revisions
Jump to navigation
Jump to search
(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…') |
No edit summary |
||
Line 39: | Line 39: | ||
} | } | ||
</source> | </source> | ||
[[Category:Progamming]] | |||
[[Category:Snippit]] |
Revision as of 19:25, 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" );
}
}