This plugin will enable advanced player ranking and stat tracking on multiple Left 4 Dead servers. Unlike other ranking plugins which emphasize personal awards and advancement, L4D Player Stats awards players both for personal achievements as well as Team goals. Working as a team is more rewarding than simply getting the most kills!

If you have any ideas, suggestions, or issues - Please post them!

And yes, L4D Survival and Versus stats are coming VERY soon!

Requirements

PHP (5.0 is recommended, older versions may work but are NOT supported!)

MySQL (5.0 is recommend, older versions may work) (*** External connections required if your MySQL server is not on the same system ! This is not enabled by default, you may need to contact your host! ***)

Existing MySQL database

Metamod: Source/SourceMM (Latest Version)

SourceMod (1.2 Latest Build)

Clientprefs extension

Installation

Edit the config.php file with the database information for your MySQL database. Upload the webstats files to your web space.

Run the createtable.php script from a web broswer. Delete this file if the tables are created successfully.

chmod 777 the /templates/awards_cache.html file. Not doing so may cause the Awards cache not to run properly!

Upload the plugin to your /addons/sourcemod/plugins/ directory on your game server.

Edit your databases.cfg file and add a section with the following information:

Upload the latest version of the files. You may need to add new sections to your config.php file, refer to the webstats changelog. You can simply update the example config.php with your MySQL information and overwrite your old config.

Run the updatetable.php file from a web browser. This will make any changes necessary to your database layout.

Configuration

The configuration file l4d_stats.cfg should be created automatically after loading the plugin. Refer to this file for full cvar information, the following settings are configuration cvars only. It is not necessary to change these, however you may do so to change the behavior of L4D Stats.

sm_l4dstats_announcemode - Behavior of stats announcements when points are awarded. 0 = off, 1 = Player only, 2 = Player only with Public headshots, 3 = all Public. Warning: All Public is VERY annoying, it is not recommended!

sm_l4dstats_medkitmode - Method for which players are given points for healing friendlies with Medkits. 0 = Dynamic point based on amount healed, 1 = Static point amount.

Frequent Questions / IssuesMy database is on the same server as my game server, but using localhost in my database.cfg is not working.
Try setting it to "127.0.0.1". This will force the TCP/IP interface instead of the hardcoded filesystem socket, since SourceMod seems to use a hardcoded path. (Thanks for this one Dopefish!)

Do I need to use MySQL for the stats AND clientprefs?
No, you technically only need MySQL for the stats. You can use the local SQLite database for clientprefs if you want, the only variable that it is used for is temporary and is reset fairly often.

I am getting blank name entries in my players table.
Try running the updatetable.php file included with the latest webstats zip file.

My awards page is showing up blank after I install / upgrade.
Your rank award is using the default, blank cache file. Set your award cache setting to 0, to disable cacheing. Then reload the award page. This should force it to generate a new award listing. If it does, you can safely set your cache setting back to the value it was before. If you still have issues, post here.

Will you make a version that tracks by player name or IP address instead of SteamID?
No, because you are probably using nosteam. No Steam, No Support. Pay for Valve's games you cheap fuck!

On the player stats pages, it always says "Community URL Disabled." How do I enable this?
You need to recompile PHP to support BCMath. You may need to ask your webhost to do this. The configure option is: '--enable-bcmath'

Changelog

Plugin

Code:

-- 0.1.0 (1/8/09)
. Initial closed beta release!
-- 0.1.1 (1/9/09)
. Silenced plugin disable alerts, except "not enough Human players" alert.
. Removed misc debug message.
. Fixed misc error log messages.
-- 0.1.2 (1/12/09)
. Testing new interstitial SQL method for Common Infected kill tracking.
Instead of sending a SQL transaction after each kill, only send SQL during
the update period when Common Infected points are displayed. The high
amount of SQL traffic causes noticible lag during high combat periods,
such as when a mob attacks.
-- 0.1.6 (1/13/09)
. Fully implimented interstitial SQL update for Common Infected. Added
check to send update when a player disconnects, so no points are lost if
they disconnect between interstitial updates.
. Cleaned up code a bit.
. Improved player name sanitation.
. Changed new players playtime to init at 1 instead of 0.
. Changed point amounts from static values to Cvar values.
. Added Cvar to control how stats messages are displayed to players:
0 = Stats messages are off
1 = Messages sent to the player who earned them only
2 = Same as 1, but Headshots on Special Infected are globally anounced
3 = All messages are global. Warning: This is VERY annoying!
. Added Cvar to control whether Medkit points are given based on the amount
healed, or a static amount set by Cvar. Amount healed is 0.5x in Normal,
1x in Advanced, and 2x in Expert.
. Added check to disable stats if the Database connection has failed.
-- 0.1.8 (1/15/09)
. Further cleaned up code.
. Optimized UTF8 character support.
. Removed log message on successful database connection.
. Added threaded query to player inserting, to check if the player already
exists and if so, don't attempt to INSERT IGNORE them.
. Reformatted rank panels.
. Added Cvar to list community site for more information in "rank" panel.
. Removed table generation from the plugin. This will be handled by a
setup script provided with webstats.
-- 0.1.9 (1/16/09)
. Changed all updates to threaded queries, to fix lag caused by updates and
server timeouts in rare cases.
-- 1.0.0 (1/18/09)
. Initial public release!
-- 1.1.0 (1/28/09)
. Fixed change in update/Common Infected announcement timer not obeying
changes to the cvar, except when in the config file and the plugin/server
is restarted.
. Fixed team chat not picking up chat triggers.
. Added invalid database connection checking to rank/top10 panel display.
. Fixed bug where players would be inserted into the database, but their
user data would not get updated and they would appear blank.
. Removed plugin version from showing up in the config file.
. Removed "Not enough Humans" message when in Versus.
. Made rank panel display after client connect at the start of each map,
and added cvar to enable/disable this.
. Made "Playtime" display hours if the playtime is longer than 60 minutes.
. Added cvar to hide the display of public chat triggers.
-- 1.1.1 (4/22/09)
. Changed "IsVersus()" function to "InvalidGameMode()" to fix deadstop bug
with the Survival update. This is part of paving the way to Survival
and Versus stats in a future release.
. Fixed various error messages in error logs.
. Fixed stats panel to now work properly for people with certain characters
in their name not making it display.
. Fixed (again) a certain case where blank users would be inserted.
. Added cvar to enable/disable showing of the rank panel when not in a valid
gamemode, showing of disabled messages, and letting players use the chat
commands.
. Added some stat whoring checks to the plugin:
. A maximum amount of points can be earned in a single map
. Only 3 Tanks may be awarded during a single map
. Fixed minor bug with Healthpack point award not giving full amount.
. Added a few currently unused cvars for future features:
. sm_l4dstats_dbprefix -- Prefix to be used for database tables
. sm_l4dstats_enablecoop -- Enable stats for Coop mode
. sm_l4dstats_enablesv -- Enable stats for Survival mode
. sm_l4dstats_enableversus -- Enable stats for Versus mode
. sm_l4dstats_leaderboardtime -- Duration in days to show players top
times on the Survival leaderboards

Webstats

Code:

-- 0.1 (1/12/09)
. Initial release!
-- 0.2 (1/13/09)
. Fixed "Headshot Ratio" award from being calculated when the conditions have
not been met
. Fixed recently added players not being listed on the Player List page, but
breaking page count
. Disabled "Community URL" when BCMath is not compiled in PHP
. Added error message when invalid campaign name is selected
-- 0.3 (1/15/09)
. Fixed typos on Awards page
. Added "Minimum Points" requirement for "Headshot Ratio" award
. Added "Minimum Playtime" requirement for all awards
. Fixed UTF8 characters not displaying properly - thanks psychonic!
-- 1.0 (1/18/09)
. Initial public release!
. Changed Team Kill and Friendly Fire awards to ignore minimum playtime
-- 1.1 (1/28/09)
. Fixed "createtable.php" to properly set the collation and character set of
tables at creation
. Fixed minor formatting issue with Campaigns page
. Added "updatetable.php" file to update tables from previous versions to
latest table layout
. Removed unnecessary code from Awards page
. Added "Minimum Points" requirements for all awards
. Added "file_get_contents()" function to common.php in the instance that it
does not function properly with existing PHP5 installs.
. Added new "Population Comparison" system, as well as the beginning of
individual player achievements. You can now compare your entire server's
kill count, individual Campaign kill counts, and individual player kill
counts to city, county, and state populations in the US!

Special Thanks
DopeFish, Icettiflow, jasonfrog, liv3d, and everyone at F7Lans for helping me beta test in the weeks before release. There are several bugs I would not have caught had it not been for them. Thank you!

Quick question: Will the versus stats tracking be integrated, i.e. part of the current interface, or will it be a completely different system?

It will most likely be an entirely separate plugin, with a separate (but similar) web interface. Versus is so different from Co-op that, while I can re-use some of the code I have written here, I will definitely have to make a lot of changes.

I will start working on the Versus plugin soon, I need to take a bit of a break from SM since this was a pretty intense month or so writing this. I'll probably start another megathread over in Ideas/Requests since I am not sure what people would even want out of Versus stats.

for the common kills you may want to just collect the stats from here instead of tracking each event. I could see the method your using now getting lagged on a host like mine where I am spawning about 10x the amount of common and infected hosts compared to a normal vanilla install.

I use these now in the common kills tracker and they are reliable to get the data and then insert into the DB.

These ONLY track the 'common' zombie figures for headshots and standard kills.

I am going to give this plugin a shot and see how it goes on my hosts but I am little concerned it wont be able to keep up. We see a min of about 5-10K kills per 'stage' and upwards of 20K+ per campaign on my hosts so this will give it a good run.