Go Back   Seriously! Forums > Serious Sam Series > Serious Sam HD > Serious Sam HD Workshop

Serious Sam HD Workshop The official forum for Serious Sam: HD projects, be it maps, mods, or something else.

Thread Tools Search this Thread Rate Thread Display Modes
Old 08-28-2013, 02:00 PM   #1   Add To Ignore List  
🐱 Kitty 💘💙💚💛💜
Scratch's Avatar
Crackshell Developer
Joined: May 2007
Location: Heiloo, Netherlands
Scratch is offline
Post Tracking players programatically via dedicated server log

Figured I'd share some information on how to properly track dedicated server logfiles for purposes such as making player rankings. I've written this a long while ago back when I was working on The Serious Ranker (, which is offline now. This was also used for dedicated servers to track players with an admin web-interface, which is also offline now. So here it is, SE3LogParsing.txt in its entirety. You're welcome, programming server admins..

(Note: This guide should also work for game clients running listen servers [starting a server ingame], though be careful that for the person hosting the server, it never prints a "Server accepted" message.)

How to properly track players in Serious Engine 3 servers

First off, here's a helper function you might need:

  string HtmlDecode(string strText)
    string ret = strText;
    ret = ret.Replace("&lt;", "<");
    ret = ret.Replace("&gt;", ">");
    ret = ret.Replace("&quot;", "\"");
    ret = ret.Replace("&apos;", "'");
    ret = ret.Replace("&amp;", "&");
    ret = ret.Replace("\\n", "\n"); // questionable
    return ret;
And a structure to keep player info:

  public class Player
    public bool Spectating = true;
    public string SteamID = "";
    public string Name = "";
    public int Kills = 0;
    public int Deaths = 0;
So, we're going to assume you have a connection with your server log, either via stdout, logfile or rcon.
Read everything line by line, without the timestamp ("16:31:20 LOG: ", that's 16 characters [3 spaces], only appears in logfile)

There's a couple bugs in the dedicated server that are not fixed yet, so this guide will explain some workarounds for those.

On " START OF LOG --------", or other way of knowing that the server starts, clear the playerlist.

On "Exiting server - all players left.", confirm that the amount of players in the server is > 0. If not, you didn't follow this guide correctly.

When line starts with "Server accepted connection from IP: ", parse the line to get the Steam ID (example: "110000104235bcb"), and add it to the list of players (remember SteamID in player structure!) without a name.
In above situation - as a workaround for a bug - also get the player's index. (Split on ": " and ", " and ".", then take index 1 for the Steam ID and index 3 for the player index.)
Remember above mentioned player index in a string PlayerIndices[16] (initialize array with all empty strings), and use it like this: PlayerIndices[iPlayerIndex] = strSteamID;
Steam ID in this line could potentially already be in the playerlist due to a bug - so make sure that it's not already there before you add it.

When line starts with either of these 3:
"Server received a disconnect message from "
"Server sent a disconnect message to "
"Server terminating client "
Parse the line to get the player index. (Split on "from " and "to " and "client " and ".", then take index 1)
Then remove player with that particular Steam ID from the playerlist using the steam ID we saved in PlayerIndices in the connection part above.
Set the Steam ID in the PlayerIndices array to "".

Let's talk about the printed XML tags for a second. XML tags are printed in the following formats (examples):
<playerjoined player="fra_gaz_97" playerid="11000010665d95e"/>
<playerleft player="fra_gaz_97" playerid="11000010665d95e"/>
<roundstart gamemode="TeamSurvival" fraglimit="20" timelimit="10" goalslimit="10" minplayers="2" maxplayers="8" joininprogress="0"/>
<playerkilled player="PassiLPinsever" playerid="11000010732efb1" killerclass="Walker" damagetype="Explosion" damageinflictorweapon="" killerplayer="" killerplayerid=""/>
<chat player="Captain Mainwaring" playerid="110000104ae13bb">too early</chat>
For TSR, I have written a C# class that parses these XML tags perfectly. Added here as a reference: - Use that code as you wish, it shouldn't be that hard to port to any other language of your choosing.

On XML tag "roundstart", check against "joininprogress".
If it's set to 1, set all players' Spectating to true and set Kills and Deaths to 0.
If it's set to 0, you're gonna have to wait for a 2nd printout of this tag. On the first printout of the match, it's the warmup round. (People get to press F3 to get ready) On the second printout of the match, the match has started, and nobody else can join. (But they can leave!)
Also remember current round information from the tag's attributes:
On XML tag "playerjoined", use the "playerid" attribute to update the player's info in the playerlist:
Set Name to the "player" attribute using the HtmlDecode function.
Set Spectating to false.

On XML tag "playerleft", make sure the playerlist doesn't constain the "playerid" Steam ID.
If it does, something went wrong. You alternatively might want to take that oppertunity to remove it from the playerlist, but generally you shouldn't see this happen.
Even though this is printed when a player leaves the server, we don't do anything useful with it since there's a rare bug where this does not always get printed. (Reported to Croteam; bug #26664)

On XML tag "playerkilled", get the victim and player's Steam ID using the "playerid" and "killerplayerid" attributes respectively.
Sometimes, there's a kill after one of the players disconnected, so the player might not be in the playerlist. Don't count kills or deaths for those players.
If the victim Steam ID is the same as the killer Steam ID, it's a suicide. If the killer ID is an empty string, the victim got killed by something else in the world (falling into a pit, killed by an enemy, etc)
In case of death by suicide or other non-player, set the victim's Kills-- and Deaths++.
In case of death by player, set the killer's Kills++ and the victim's Deaths++.
Remember the player names as well. Set the victim's Spectating to false. (Not the killer's, because this player could potentially already be in spectator mode.) This seems to be important in Serious Sam 3, since the "playerjoined" doesn't always get printed (bug reported to Croteam).

On XML tag "chat", you now have the name of the player associated with the Steam ID in "player". Use it wisely to update the Name in the playerlist.

Optional tracking:

When line starts with "Stopping world '", it's the end of the match.
Here you can go through the tracked playerlist to save statistics or do other things.

When line starts with "Started loading world \"", remember the current map by parsing the line. (Split on '"', then take index 1)
I'm a cat by the way. I'm also everyone's most hated critic.
(Opinions expressed are my own)

Nimble Writer - now available on Steam,
CodeCat, my blog that I need to update - I also have a showcase, which I barely update.
(I do not respond to PM's about Serious Sam Revolution or Bogus Detour. Please use the appropriate community hubs for that.)

Last edited by Scratch; 08-28-2013 at 02:25 PM. Reason: Mistake with "roundstart" xml tag; added SimpleXMLReady example class reference; added XML tag examples
  Reply With Quote


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cant start the game!!!! Marko J Serious Sam 3 8 02-09-2013 07:43 PM
1 second freeze when switching weapons (only secret ones) Drowning witch Serious Sam 3 8 01-14-2012 05:21 AM
Crashing my computer Gibbleguts Serious Sam 3 4 12-31-2011 12:56 PM
Serious Sam 2 doesn´t start Weckicrush Serious Sam 2 13 12-23-2005 01:45 PM

All times are GMT -4. The time now is 07:06 PM.