CS2 server plugin
CS:DM uses a Valve Server plugin (VSP) to communicate with CS2 and control the demo playback.
Why?
For CS:GO, we use the -netconport
launch option to communicate with the game and VDM files to control the demo playback.
Unfortunately, VDM files don't work with CS2, and the -netconport
launch option works only with the -tools
launch option available only on Windows.
As a workaround, we use a VSP that communicates with CS2 through a WebSocket connection and mimics VDM files by reading a JSON file.
Developing
Requirements
Windows
Visual Studio 2022 with the component Desktop development with C++
.
Linux
sudo apt install make build-essential
Building
The binary will be placed into the static
folder located in the project root.
CS:DM copy/paste the binary into the CS2 game folder when the game is launched.
Windows
git submodule update --init --recursive
- Open a
Visual Studio Developer Command Prompt
and navigate to the project folder msbuild cs2-server-plugin.sln
You can also build the project from Visual Studio.
Linux
git submodule update --init --recursive
make
Installation
CS:DM automatically installs
the plugin when CS2 is launched.
It does the following:
- The plugin binary is copied from the
static
folder to thegame\csgo\csdm\bin
CS2 folder. - A reference to the plugin is added to the file
game\csgo\gameinfo.gi
:
SearchPaths
{
Game_LowViolence csgo_lv // Perfect World content override
+ Game csgo/csdm
Game csgo
Game csgo_imported
Game csgo_core
Game core
- CS2 is launched with the launch option
-insecure
Uninstallation
CS:DM automatically uninstalls the plugin when CS2 is closed.
- The
gameinfo.gi
file is restored. - The plugin binary is deleted.
The plugin restores the gameinfo.gi
file when the game starts, but if necessary, CS:DM does it as well to ensure it's
restored even if the game crashes.
Logging
Logs are visible in the CS2 console with the prefix CSDM
.
On Windows, you can also start the game with the -tools launch option to access the
VConsole that allows filtering the logs.
If CS2 crashes at startup and the console unavailable, you can use the LogToFile
function to write logs into a file csdm.log
.
On Windows the log file is located in game/bin/win64
, and on Linux in game/bin
.
Updating the sdk
The plugin is built against the AlliedModders SDK.
git submodule update --remote
- Build the project
deps/hl2sdk/interfaces/interfaces.sln
inRelease
mode - Build the
tier1
project inRelease
mode - Replace
tier1.lib
andinterfaces.lib
with the newly built ones indeps/hl2sdk/lib/public/win64
- Reset any changes
git submodule foreach git reset --hard && git clean -fd