Introduction
I have written an article which explains how to send commands to mohaa game server. In this article, I will explain how to send RCON command to Counter Strike 1.6 server.
Command Format
RCON commands sent to the game server should follow the following format:
0xFF0xFF0xFF0xFF0xFFCommand
The first five characters should be 0xFF
and after that command
which should be in byte array.
Process of Sending Command
First send challenge rcon command to server. In response, the server will give you a string which will contain a number. That number will be used to send the original command. I am calling that number as challenge code. I try to find what that number is originally called, but I am unable to find it. If anybody knows the name of that number, then please let me know. :)
After that, we send the command in the following format:
rcon "challengeCode" password command
So, for example, I want to send status command and my challenge code is 123456789
and my password is 123456
, then the format will be as follows:
rcon "123456789" 123456 status
Using the Code
I am not a professional C# coder. So, I think most of C# community will curse me for writing such a class. :) But I hope it will save a lot of time for someone.
I have made a class CSRcon
. In this class, I have added a method with the name of sendRCON
. Its signature is as follows:
public string sendRCON(string serverIp, int serverPort,
string rconPassword, string rconCommand)
Here, serverIp
is game server IP, server port is game server port, rconPassword
is the password of rcon
and rconCommand
is the command of rcon
.
Tested Games
I test the code on Counter Strike 1.6. Since Counter Strike uses Half Life, I think it should work on other games which are based on Half Life.
I am unable to test that code on Counter Strike source. But I think it may work on that as well. If somebody tests that code on Counter Strike source, then please let me know by adding comments to this article. I will be very thankful to that person.
History
- 29th October, 2008: Initial post