Update: Muukis has made an improved version of this plugin with some encoding fixes available here: http://forums.alliedmods.net/showthread.php?t=91331
This version is obsolete
Summary
Logs all chat occurring in your server(s) to a database. Based on a script bl4nk put together for #hlserveradmins on GameSurge. Multi-server friendly. Comes with a small PHP web UI to demonstrate using the database.
Installation
This plugin creates a 'chatlogs' table automatically if it doesn't exist, so simply make sure you have a sql database setup in databases.cfg, install the plugin, and set a unique sm_chatlog_id for each server.
Table Structure
Code:
+---------+------------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+------------------+------+-----+-------------------+----------------+
| seqid | int(10) unsigned | NO | PRI | NULL | auto_increment |
| srvid | varchar(255) | NO | MUL | NULL | |
| date | timestamp | NO | | CURRENT_TIMESTAMP | |
| name | varchar(32) | NO | | NULL | |
| steamid | varchar(32) | NO | MUL | NULL | |
| text | varchar(192) | NO | | NULL | |
| team | int(1) | NO | | NULL | |
| type | int(2) | NO | | NULL | |
+---------+------------------+------+-----+-------------------+----------------+
The 'type' field is a flag bits field - (type & 1) is dead, (type & 2) is teamchat. More flags may be added in the future.
Commands/CVars
- sm_chatlog_id - The ID for each server. Must be set before chat will be entered into the database. EX myserver1.cfg: sm_chatlog_id "myserver1" OR sm_chatlog_id "1". This allows you to categorize chat in your database and differentiate between servers.
- sm_chatlog_filtermode - 1 [default] causes ChatLog to log messages post-processing by other addons. This means chat messages will be logged as they are seen by players, and wont include @commands or censored chat. 0 means ChatLog will directly log 'say' commands, which will include admin messages, messages that are ultimately changed by other plugins, and might not include chat events generated by other plugins.
- If you want to use a database besides 'default', modify the SQL_TConnect(sql_Connect, "default"); line in the plugin and recompile it. It would be rather messy to make this a cvar.
Using the web UI
The small web UI that comes with this should be easy to setup. Modify the 5 $DB_ variables at the beginning of it to match your database, and set it free. This script was made on php 5.2, I didn't really test it on php4 (or much in general).
The webUI requires jQuery 1.2+ for its pretty effects. The .zip attached comes bundled with jQuery 1.3.1.
Web UI Examplehttp://nemu.doublezen.net/chatlog.php
ChangeLog
- 1.2
- Web UI should now handle srvid's that contain non-alphanumeric characters.
- "Console" (IE typing 'say' in server console/rcon) is now properly logged in both filter modes.
- Fixed a javascript bug that was breaking the ajax part of the web UI for pretty much anyone. I told you I didn't test it much!
- Changed a line to make it more obvious what to edit to use a database besides 'default'. Making this a cvar would be too messy atm (see further info in CVars section of this post)
- 1.1-r4 - the php file should now work with php setups using short tags. Short tags arn't going away until php6 it seems T_T
- 1.1-r3 - Another scrolling fix because a certain someone is really nitpicky. No change to the plugin, just a minor javascript fix in the php.
- 1.1-r2 - Fixed a scrolling bug in the php file - no changes to the actual plugin.
- 1.1 - My initial version with juicy featuretasticness.
- 1.0 - Initial version from bl4nk
Thanks
- bl4nk for writing the original plugin, which accounts for much of the plugin's code.
- msleeper, psychonic, mauirixxx, and everyone else in #hlserveradmins for requesting it, badgering me, and making fun of my taste in music.
- Nimoi for helping me test it on our servers.
- Mythical for responding to nonsensical requests on steam
- jQuery for being useful and to the point.
License
Both the plugin and the webUI example are GPL3'd. See the copyright notice in the header of both files. jQuery (used by the webUI and bundled in the zip) is dual licensed under the MIT and GPL licenses.