CS:GO User Messages

From Valve Developer Community
Jump to: navigation, search
User Messages in Counter-Strike: Global Offensive

User messages in CS:GO use Google's Protocol Buffers (protobuf). Protobuf is a message/object serialization language that generates code to serialize the objects efficiently. For information about protobuf, see https://developers.google.com/protocol-buffers/docs/overview

On Windows, follow these steps to generate C++ classes from CS:GO .proto files.

  • Download and extract csgo_usermessages.zip
  • Download the protocol buffer compiler protoc-2.3.0 and extract it into the protoc-2.3.0-win32 folder that was created when you extracted csgo_usermessages.zip. The protocol buffer compiler is required to generate C++ classes from CS:GO .proto files.
  • Download protobuf-2.3.0 and extract it into the same folder as csgo_usermessages.zip. This package contains files that are included by CS:GO .proto files
  • Run make_cc_files.bat. The generated C++ files are created in subdirectory named generated_proto.

You can now use the generated classes in your C++ code to send user messages. Here is an example of how to send the HintText message

CSingleUserRecipientFilter filter( this );
filter.MakeReliable();

CCSUsrMsg_HintText msg;
msg.set_text( "ExampleHint" );
SendUserMessage( filter, CS_UM_HintText, msg );