CS:GO User Messages: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Added writeup on protobuf format CS:GO user messages)
 
(Updated based on readme.txt. Use zip and batch files since it's cleaner)
Line 3: Line 3:
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
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. For this tutorial we'll assume all packages are extracted to the same folder and that the CS:GO .proto files are copied there as well.
On Windows, follow these steps to generate C++ classes from CS:GO .proto files.  


* Download the protocol buffer compiler [http://code.google.com/p/protobuf/downloads/detail?name=protoc-2.3.0-win32.zip&can=2&q= protoc-2.3.0] and extract it. This tool is required to generate C++ classes from CS:GO .proto files.  
* Download and extract [csgo_usermessages.zip]
* Download [http://code.google.com/p/protobuf/downloads/detail?name=protobuf-2.3.0.zip&can=2&q= protobuf-2.3.0] and extract it. This package contains files that are included by CS:GO .proto files
* Download the protocol buffer compiler [http://code.google.com/p/protobuf/downloads/detail?name=protoc-2.3.0-win32.zip&can=2&q= protoc-2.3.0] and extract it into the protoc-2.3.0-win32 folder that was created when you extracted csgo_usermessages.zip. This tool is required to generate C++ classes from CS:GO .proto files.  
* Download [[netmessages.proto]] and [[cstrike15_usermessages.proto]]. The latter contains user message definitions.
* Download [http://code.google.com/p/protobuf/downloads/detail?name=protobuf-2.3.0.zip&can=2&q= protobuf-2.3.0] and extract it into the protobuf-2.3.0-win32 folder that was created when you extracted csgo_usermessages.zip. This package contains files that are included by CS:GO .proto files
* Switch to the folder that contains all the above and compile the .proto files as follows.  
* Run make_cc_files.bat. The generated C++ files are created in subdirectory named generated_proto.
:protoc --proto_path=. --proto_path=protobuf-2.3.0\src --cpp_out=. cstrike15_usermessages.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
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

Revision as of 11:59, 3 January 2013

User Messages in CS:GO

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. This tool is required to generate C++ classes from CS:GO .proto files.
  • Download protobuf-2.3.0 and extract it into the protobuf-2.3.0-win32 folder that was created when you extracted 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 );