L4D2 statistics tracking plugin & website https://stats.jackz.me
  • SourcePawn 67.5%
  • Pascal 12.4%
  • Astro 12.3%
  • TypeScript 7.4%
  • JavaScript 0.2%
Find a file
2026-01-26 16:01:43 -06:00
.forgejo/workflows Forgot a damn comma 2025-10-12 21:04:06 -05:00
scripting Fix search using old column 2025-12-04 21:06:36 -06:00
sql Set collate for migration script 2025-11-27 14:27:42 -06:00
website Fix error when seconds_idle=0 2026-01-26 16:01:43 -06:00
.gitignore Ignore .idea 2025-12-21 19:51:45 -06:00
compile_all.sh Add missing script 2025-10-11 08:41:31 -05:00
LICENSE Line ending changes 2024-06-14 10:08:19 -05:00
README.md Update README 2025-11-27 14:43:02 -06:00

L4D2 Stats

Note

This is more of a custom personal project. This is a free project that is open sourced, so feel free to make issues and pull requests, but there's no guarentees here.

A sourcemod plugin for l4d2 that records statistics for all players on the server and a server that shows the statistics. This was designed for co-op, and so versus and other gamemodes may not track statistics correctly.

Includes a site you can host, that showcases player and game statistics, includes a leaderboard, map playtimes and ratings and more. View my server's stats site for an example at stats.jackz.me

This is a multi-part project:

  • Web server (Astro) serving HTTP templates
  • Sourcemod Plugin that records the statistics

Requires a MySQL/MariaDB server, see stats_database.sql for a setup script.

Deploying

Deploying Plugin

A precompiled plugin can be downloaded from the plugin workflow page or from the releases page. The plugin connects to the database named "stats" configured in sourcemod/configs/databases.cfg. The database must be MySQL/MariaDB, postgres is not supported.

Plugin Config

Check <game>/cfg/sourcemod/l4d2_stats_recorder.cfg to change the cvars:

  • l4d2_statsrecorder_tags - the comma separated list of server tags to record games with
  • l4d2_stats_url - the URL prefix that is appended with game id, shown on finale won

Deploying Website

Env Variables

Env variables can be set with a local .env.local file, default values can be seen in the .env file provided

# Required

DATABASE_URL=mysql://stats@localhost/left4dead2

## URL used for some links
PUBLIC_SITE_URL=https://stats.example.com
## Name of site to use in navbar, <title>
PUBLIC_SITE_NAME=L4D2 Stats
## Description used on home page and any page without it's own description
PUBLIC_SITE_DESC=View all in-game statistics for Left 4 Dead 2, with a leaderboard, game overviews and user statistics

# Optional
## Comma separated list of domains to whitelist for /api routes, or use '*' for any site
API_ALLOWED_ORIGINS=myotherservice.example.com
## Host
HOST=0.0.0.0
## Port for server to listen to
PORT=4321

Docker

Due the nature of Astro, the site URL is baked into the files on build time. No pre-built docker image is available, but you could build your own easily with the provided Dockerfile.

Pulls env variables from .env files (Vite's docs). ALL .env files are copied, so overwrite settings with .env.production if needed

docker build -t l4d2-stats .

Manual

Requires pnpm

Pulls env variables from .env files (Vite's docs)

# install dependencies
pnpm install --production

# build site for production, produces files in dist/
pnpm build

Development

Website

# install all dependencies
pnpm i

# serve dev server on localhost:4321
pnpm dev