Skip to content

Player Stats System

Warning

None of the methods for collecting stats are going to be reliable if get5_check_auths is set to 0.

SourceMod Forwards

If you're writing your own plugin, you can collect stats from the game using the forwards provided by Get5.

HTTP Events

If you want to send stats to a web server, the HTTP event system will let you collect game information at any level of granularity by sending data as JSON over HTTP(S); from grenades thrown, kills, player chat messages to round, map or series results.

KeyValue System

Get5 will automatically record basic stats for each player for each map in the match. These are stored in an internal KeyValues structure, and are available at any time during the match (including the postgame waiting period) via the Get5_GetMatchStats native and the get5_dumpstats command.

The root level contains data for the full series; the series winner (if one exists yet) and the series type (bo1, bo3, etc.) and the team names/IDs.

Under the root level is a level for each map (map0, map1 etc.), which contains the map winner (if one exists yet), the map name and the demo file recording.

Under the map level is a section for each team (team1 and team2), which contains the current team score (on that map), the score for each side on that map (CT vs. T) and the side the team started on as well as an object with player stats (players) for the entire team, saved under each player's SteamID64.

Example

get5_matchstats.cfg

"Stats"
{
    "series_type"  "bo1"
    "team1"
    {
        "id"    "23758"
        "name"  "EnvyUs"
    }
    "team2"
    {
        "id"    "15716"
        "name"  "Fnatic"
    }
    "winner"  "team1"
    "map0"
    {
        "mapname"        "de_mirage"
        "demo_filename"  "304_map1_de_mirage.dem"
        "winner"         "team1"
        "team1"
        {
            "players"
            {
                "76561197996426755"
                {
                    "init"                "1" // internal init key, ignore this
                    "coaching"            "0" // 1 if the player is a coach
                    "name"                "xyz"
                    "kills"               "9"
                    "deaths"              "3"
                    "assists"             "5"
                    "flashbang_assists"   "2"
                    "teamkills"           "0"
                    "suicides"            "0"
                    "damage"              "945"
                    "util_damage"         "34"
                    "enemies_flashed"     "4"
                    "friendlies_flashed"  "1"
                    "knife_kills"         "0"
                    "headshot_kills"      "3"
                    "roundsplayed"        "8"
                    "bomb_defuses"        "1"
                    "bomb_plants"         "0"
                    "1kill_rounds"        "1"
                    "2kill_rounds"        "2"
                    "3kill_rounds"        "1"
                    "4kill_rounds"        "0"
                    "5kill_rounds"        "0"
                    "v1"                  "3" // 1v1s won
                    "v2"                  "2"
                    "v3"                  "1"
                    "v4"                  "0"
                    "v5"                  "0"
                    "firstkill_t"         "0"
                    "firstkill_ct"        "2"
                    "firstdeath_t"        "0"
                    "firstdeath_ct"       "2"
                    "tradekill"           "4"
                    "kast"                "8"
                    "contribution_score"  "23"
                    "mvp" "4"
                }
            }
            "score"          "5" // total rounds won
            "score_ct"       "2" // rounds won on CT
            "score_t"        "3" // rounds won on T
            "starting_side"  "3" // 3 for CT, 2 for T  
        }
    }
}

KeyValues != JSON

Please note that the JSON events have similar - but not identical - structure and keys to this file. The KeyValues system is inferior to the JSON-based HTTP system in many ways, and most modern integrations would likely be better off using JSON, especially if data is being sent to a web server.

MySQL Statistics

Get5 ships with a (disabled by default) plugin called get5_mysqlstats that will save many of the stats to a MySQL database. You can use the included plugin as a source of inspiration and build your own to collect even more stats, or even wrap a website around it for managing matches. The included plugin is meant as a proof-of-concept of this functionality, but can also be used as-is.

Fixed Match IDs

If you use the MySQL extension, you should not set the matchid in your match configuration (just leave it empty) or when creating scrims or matches using the get5_scrim or get5_creatematch commands. The match ID will be set to the auto-incrementing integer (cast to a string) returned by inserting into the get5_stats_matches table.

Advanced users only

You should have a basic understanding of MySQL if you wish to use this plugin. It is assumed you know what the commands below do.

  1. Make sure the get5_mysqlstats.smx plugin is enabled (moved up a directory from addons/sourcemod/plugins/disabled directory).

  2. Have a MySQL server reachable from the game server's network. These commands are for MySQL 8 but should also work on MySQL 5.7.

  3. Create a schema/database for your tables:

    CREATE SCHEMA `get5` DEFAULT CHARACTER SET `utf8mb4` COLLATE `utf8mb4_0900_ai_ci`;
    USE `get5`;
    
    ⚠ The utf8mb4 part ensures that your database can handle all kinds of emojis and unicode characters. This is the default in MySQL 8 but must be explicitly defined for MySQL 5.7.

  4. Configure a database user and grant it access to the database:

    CREATE USER 'get5_db_user'@'%' IDENTIFIED WITH mysql_native_password BY 'super_secret_password';
    GRANT ALL ON `get5`.* TO 'get5_db_user'@'%';
    
    ⚠ You can use the root database user instead if you wish. @'%' means that the user can log in from any network location, and you can replace this with @'localhost' if your database is running on the same host as the game server.

  5. Create the required tables using these commands. Raw text link can be found here.

  6. Configure a "get5" database section in SourceMod and provide the parameters you used to configure your database:

addons/sourcemod/configs/databases.cfg

"get5"
{
    "driver"   "mysql"
    "host"     "127.0.0.1"
    "database" "get5"
    "user"     "get5_db_user"
    "pass"     "super_secret_password"
    "port"     "3306"
}