Skip to content

A simple Sinatra-based score/statistics tracker for Counter-Strike

Notifications You must be signed in to change notification settings

stevenocchipinti/CS_Scoreboard

Repository files navigation

Counter Strike Scoreboard

by Steven Occhipinti

Intro

This is my first Sinatra app. The goal of this app is to parse log data from a Counter Strike server and present it as a live updating scoreboard. This started out as a joke at a LAN party and I thought the idea was a good simple app for me to give Sinatra a go.

The basics

This app is broken into 3 parts:

Counter Strike server

A Counter Strike server can be configured to send log data to a server listening on a pre-defined UDP port. To accomplish this, the following commands need to be executed in the server console: log on logaddress_add : I would recommend putting these commands in the servers server.cfg file to be automatically executed when the server is started. Note: localhost and 127.0.0.1 will not work, see below.

daemon.rb

daemon.rb listens on a UDP port for logging information. When it receives data, it will run them through some known regular expressions. If there is a match, that event is written to an SQLite3 database.

scoreboard.rb

scoreboard.rb is a Sinatra app that reads the database and presents an auto-updating scoreboard using AJAX.

Installation and Usage

To get up and running:

bundle install
bundle exec ruby scoreboard.rb

When you browse to root URL of the app it will start the daemon process in the background. You can check the status of the daemon with the /daemon path. You should then be redirected to the /scores path where the scoreboard will be displayed.

Adding CS-Scoreboard as a service on Linux

If you decide you want to run this permanently on your server (such as for a dedicated gaming vps or something) there is a wrapper.rb script included that handles the basic start, stop and status commands that you can add to your system service configuration. This will control the Sinatra app which provides a GUI for controlling the background daemon.rb process.

Logging statistics on localhost

There is a bug in srcds where when the logaddress_add command contains either localhost or 127.0.0.1, nothing is actually sent. The work around for this bug is to use a different /etc/hosts file entry for the loopback address. For example, if the hostname is srcds, daemon.rb should look like this:

sock.bind("srcds", port)

This works because by default the /etc/hosts file contains an entry like this:

127.0.1.1	srcds

If it doesn't have a entry based on the hostname, this needs to be added.

About

A simple Sinatra-based score/statistics tracker for Counter-Strike

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages