Click here to Skip to main content
15,891,567 members
Articles / Programming Languages / C#

Send RCON command to Counter Strike

Rate me:
Please Sign up or sign in to vote.
3.22/5 (7 votes)
29 Oct 2008GPL32 min read 65.8K   1.4K   9   12
In this article, I will explain how to send RCON commands to Counter Strike 1.6
Image 1

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:

C#
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

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer (Senior) EBusiness
Pakistan Pakistan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalcod4 Adjustment Pin
Steve Moorhouse21-May-10 4:59
Steve Moorhouse21-May-10 4:59 
GeneralRe: cod4 Adjustment Pin
Waqas Badar1-Jun-10 3:20
Waqas Badar1-Jun-10 3:20 
GeneralMy vote of 2 Pin
Fred Blom29-Jun-09 10:26
Fred Blom29-Jun-09 10:26 
GeneralRe: My vote of 2 [modified] Pin
Waqas Badar29-Jun-09 19:56
Waqas Badar29-Jun-09 19:56 
GeneralDoesn't work Pin
KbCb2-Jun-09 11:14
KbCb2-Jun-09 11:14 
GeneralRe: Doesn't work Pin
Waqas Badar2-Jun-09 20:22
Waqas Badar2-Jun-09 20:22 
GeneralRe: Doesn't work Pin
KbCb3-Jun-09 5:38
KbCb3-Jun-09 5:38 
GeneralRe: Doesn't work Pin
Waqas Badar3-Jun-09 21:18
Waqas Badar3-Jun-09 21:18 
GeneralRe: Doesn't work Pin
KbCb4-Jun-09 3:27
KbCb4-Jun-09 3:27 
GeneralCSSource Pin
hyposnike4-Dec-08 19:28
hyposnike4-Dec-08 19:28 
GeneralGood Concept Pin
sinklink29-Oct-08 4:12
sinklink29-Oct-08 4:12 
GeneralRe: Good Concept Pin
Waqas Badar29-Oct-08 19:57
Waqas Badar29-Oct-08 19:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.