Arie’s Blog

Eggdrop script for controlling HLTV’s

August31

As one of the founders of online gaming community #cs.gather.nl, part of the Gather Network, I’ve had quite some dealings with people cheating in online games, and people calling eachother cheaters.There are various ways to fight cheaters in the game Counter-Strike. First there’s the built-in anti-cheat from the developer, Valve, called Valve Anti-Cheat. Despite it’s name, it does little against most popular cheats.Second there’s a global blacklist of cheaters, called Steambans. This will stop people who have cheated before and have been caught by an alert admin, who submitted a recording of the cheater’s actions to Steambans.

Third, admins of the match can request a player to record his actions to a so called ‘demo’. If the user would be cheating this would show on a demo. However, no sane player would still cheat while recording a demo.
A few years ago Valve released a piece of software that allows you to watch matches. This software was created due to the increasing popularity of Counter-Strike as an “e-Sports’ game.

The software, called HLTV, is basically a proxy server that allows people to watch a match without overloading the gameserver. It has a built-in delay, so that spectating people can’t give vital informatin, like enemy positions, to the players with tools as direct messaging and voice communication.

HLTV is also able to record a demo. The great advantage of demo’s recorded by HLTV is that the single HLTV demo records all the actions of all players, and players don’t have to do anything. If an admin suscpects someone is cheating, he would go into the HLTV console and record a demo. When the match is over he could send this file to him and watch for cheats.

However, with about 30 admins in #cs.gather.nl who normally stay for just a few weeks, it’s not possible to give them shell access to a Debian GNU/Linux machine and control the HLTV consoles. It would be much easier to communicate with the HLTV consoles from IRC and only allow operators from #cs.gather.nl (the admins) to execute commands.

To do this, you need an automated chat client, a bot, and a specially written program for ths bot, a script. I had seen IRC bots that appeared to be controlling HLTV’s, but never found a script that was freely available. It also appeared that most bots depended on so-called “remote console” connections to the HLTV’s.

The remote console, or rcon, is a way of remotely controlling consoles of gameservers. Unfortunately, the developer of Counter-Strike has changed this protocol in the past a few times, leading to non-functional scripts/bots.

I also wanted to try another method of talking to the HTLV consoles. I’ve decided to let the bot talk to the HLTV consoles using the “screen” command. Screen is a GNU tool for running programs in the background. Whenever you want you can bring it back to the foreground and execute commands. It’s also possible to send commands to a screen in the background and get information from a screen running in the background.

The downside of this approache compared to the remote console approach is that all HLTV proxy’s have to run on the same physical computer as the bot controlling them. But at that cost, it is more reliable and faster to talk to the HLTV proxy’s.

To setup your own HLTV’s which you control with a bot:

Prerequisites:

Eggdrop bot

Instructions for installing eggdrop can be found at www.eggheads.org

Screen

On Debian/Ubuntu simply apt-get install screen

Step 1 – Install HLTV

wget http://www.ariekanarie.nl/tutorials/hltv.tar.bz2

tar vfxj hltv.tar.bz2

Set up hltv.cfg and hltv.sh according to your configuration.
Step 2 – Runnng HLTV

You have to run HLTV in a screen. The TCL script will send commands to this screen. If you want to run multiple HLTV’s, simply copy the installation directory and make the hltv run in a different screenname. You have to run HLTV with the same username as the eggdrop bot, else the eggdrop script can’t send commands to the screen sessions.
Step 3 – Installing/Configuring the HLTV TCL script

First download the hltv script here and put it in your eggdrop/scripts directory.
Open hltv.tcl with your favorite text editor and change the following variables to what you need/like.

set hltv_channel “#cs.gather.nl”
set hltv_command “!hltv”

Put the names of the screen sessions in a space seperated list.

For example, my hltv screen names are hltv1, hltv2, hltv3, etc…

set hltv_screens {hltv1 hltv2 hltv3 hltv4 hltv5}

Step 4 – Loading the HLTV TCL script

Open the config file of your eggdrop, and scroll down to the part where all scripts are loaded. Add the following line:

source scripts/hltv.tcl

Save and exit the editor. Rehash the bot to load the script

Commands for the script

!hltv status – Detailed statusreport
!hltv stat – Basic statusreport
!hltv connect ip:port password (optional) – Connect to server, takes optional password argument
!hltv record demoname – Starts demorecord with name
!hltv stop – Disconnects from server
!hltv stoprecord – Stops demorecording on
!hltv status – Detailed statusreport for

posted under Programming, Tutorials
9 Comments to

“Eggdrop script for controlling HLTV’s”

  1. On September 7th, 2006 at 01:09:43 d4rk Says:

    Great script, very usefull and advanced! Keep up the good work and you might become my guru. :D

  2. On October 22nd, 2008 at 02:10:27 AE Says:

    where the demo goes when you make one? ty nice script

  3. On November 22nd, 2008 at 16:11:25 enza Says:

    Hmm.. On the win xp this bot on? For me not use this script

  4. On November 22nd, 2008 at 16:11:10 Arie Says:

    Nope, not going to work on Win XP.

  5. On March 14th, 2009 at 03:03:04 anonymous Says:

    Well its usefull only for those who can bring bot and hltv to 1 pc, it would be more usefull to be able control hltv when bot is on other pc. Useless for me, anyway GJ!

  6. On March 14th, 2009 at 04:03:03 Arie Says:

    Use the TCL RCON module :)

  7. On May 15th, 2009 at 01:05:28 anonymous Says:

    Use the Rcon mod? That way i should rewrite almost all script exept binds O_O .. Well maby not all, must look inside when i’m free..

  8. On March 30th, 2010 at 12:03:29 maR3 Says:

    [09:58] Tcl error [hltv_main]: No screen session found.
    child process exited abnormally

    Any Ideas on how to fix this? :)

  9. On March 31st, 2010 at 10:03:06 Arie Says:

    I’d guess your HLTV never got started properly, so it can’t reconnect to it either.

Email will not be published

Website example

Your Comment: