Initial release 1.0.0
Browse Source1.0.0 - Initial release.
4 changed files
with 180 additions and 0 deletions
A
CHANGELOG.md
+3 -0
A
README.md
+1 -0
A
addons/amxmodx/scripting/csb_chat_logger.sma
+134 -0
A
csb.json
+42 -0
CHANGELOG.md
A
| @@ -0,0 +1,3 @@ | ||
| 1 | +## 1.0.0 (2025-10-26) | |
| 2 | + | |
| 3 | +1.0.0 - Initial release. |
README.md
A
| @@ -0,0 +1 @@ | ||
| 1 | +<p><strong>CSB Chat Logger</strong> writes a permanent record of in-game chat for moderation. Every <code>say</code> and <code>say_team</code> line is captured with a timestamp, channel, team, player name and SteamID and appended to a per-day file (<code>csb_chat_YYYY-MM-DD.log</code>) with <code>write_file()</code>. The last 20 lines are also kept in memory so an admin can run <code>amx_lastchat</code> and read recent chat straight in their console without opening a file.</p><h2>Features</h2><ul><li>Hooks <code>say</code> and <code>say_team</code> without swallowing them — messages still reach normal chat.</li><li>Per-day log file, one line per message: <code>[HH:MM:SS] (ALL) TEAM Name <STEAM_ID>: text</code>.</li><li><code>amx_lastchat</code> prints an in-memory ring buffer of the most recent 20 lines to the caller's console.</li><li>Skips empty messages and <code>/</code> or <code>!</code> command-style lines so the log is not polluted by other plugins' menus.</li><li><code>csb_chatlog_tofile</code> lets you keep only the in-memory buffer if you do not want files on disk.</li></ul><h2>Installation</h2><ol><li>Compile <code>csb_chat_logger.sma</code> and copy it to <code>addons/amxmodx/plugins/</code>.</li><li>Add it to <code>plugins.ini</code> and change the map.</li></ol><p>Log files are written under <code>addons/amxmodx/logs/</code> (the AMXX logs directory) by default. <code>amx_lastchat</code> needs the <code>ADMIN_KICK</code> flag (<code>c</code>).</p> |
addons/amxmodx/scripting/csb_chat_logger.sma
A
| @@ -0,0 +1,134 @@ | ||
| 1 | +/* | |
| 2 | + * CSB Chat Logger | |
| 3 | + * Copyright (C) 2026 counter-strike-boost.com | |
| 4 | + * | |
| 5 | + * Captures every say / say_team message with the player's name, SteamID, team | |
| 6 | + * and alive state and appends it to a per-day log file. Admins can run | |
| 7 | + * amx_lastchat to dump the last lines held in memory to their console. | |
| 8 | + * | |
| 9 | + * This program is free software: you can redistribute it and/or modify it under | |
| 10 | + * the terms of the GNU General Public License as published by the Free Software | |
| 11 | + * Foundation, either version 3 of the License, or (at your option) any later | |
| 12 | + * version. It is distributed in the hope that it will be useful, but WITHOUT | |
| 13 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 14 | + * FOR A PARTICULAR PURPOSE. See <https://www.gnu.org/licenses/> for details. | |
| 15 | + */ | |
| 16 | + | |
| 17 | +#include <amxmodx> | |
| 18 | +#include <amxmisc> | |
| 19 | + | |
| 20 | +new const PLUGIN[] = "CSB Chat Logger" | |
| 21 | +new const VERSION[] = "1.0.0" | |
| 22 | +new const AUTHOR[] = "counter-strike-boost.com" | |
| 23 | + | |
| 24 | +#define MAX_BUFFER 20 | |
| 25 | +#define LINE_LEN 160 | |
| 26 | + | |
| 27 | +new g_pEnabled, g_pToFile | |
| 28 | +new g_szBuffer[MAX_BUFFER][LINE_LEN] | |
| 29 | +new g_iBufCount = 0 | |
| 30 | +new g_iBufHead = 0 | |
| 31 | + | |
| 32 | +public plugin_init() | |
| 33 | +{ | |
| 34 | + register_plugin(PLUGIN, VERSION, AUTHOR) | |
| 35 | + | |
| 36 | + g_pEnabled = register_cvar("csb_chatlog_enabled", "1") | |
| 37 | + g_pToFile = register_cvar("csb_chatlog_tofile", "1") | |
| 38 | + | |
| 39 | + register_clcmd("say", "cmdSay") | |
| 40 | + register_clcmd("say_team", "cmdSayTeam") | |
| 41 | + | |
| 42 | + register_concmd("amx_lastchat", "cmdLastChat", ADMIN_KICK, "- dump the last chat lines to your console") | |
| 43 | +} | |
| 44 | + | |
| 45 | +public cmdSay(id) | |
| 46 | +{ | |
| 47 | + logChat(id, "ALL") | |
| 48 | + return PLUGIN_CONTINUE | |
| 49 | +} | |
| 50 | + | |
| 51 | +public cmdSayTeam(id) | |
| 52 | +{ | |
| 53 | + logChat(id, "TEAM") | |
| 54 | + return PLUGIN_CONTINUE | |
| 55 | +} | |
| 56 | + | |
| 57 | +logChat(id, const channel[]) | |
| 58 | +{ | |
| 59 | + if (!get_pcvar_num(g_pEnabled)) | |
| 60 | + return | |
| 61 | + | |
| 62 | + new said[128] | |
| 63 | + read_args(said, charsmax(said)) | |
| 64 | + remove_quotes(said) | |
| 65 | + trim(said) | |
| 66 | + | |
| 67 | + if (!said[0]) | |
| 68 | + return | |
| 69 | + | |
| 70 | + /* ignore command-style messages handled by other plugins */ | |
| 71 | + if (said[0] == '/' || said[0] == '!') | |
| 72 | + return | |
| 73 | + | |
| 74 | + new name[32], authid[35] | |
| 75 | + get_user_name(id, name, charsmax(name)) | |
| 76 | + get_user_authid(id, authid, charsmax(authid)) | |
| 77 | + | |
| 78 | + new teamName[16] | |
| 79 | + get_user_team(id, teamName, charsmax(teamName)) | |
| 80 | + | |
| 81 | + if (!teamName[0]) | |
| 82 | + copy(teamName, charsmax(teamName), "SPEC") | |
| 83 | + | |
| 84 | + new stamp[24] | |
| 85 | + get_time("%H:%M:%S", stamp, charsmax(stamp)) | |
| 86 | + | |
| 87 | + new line[LINE_LEN] | |
| 88 | + formatex(line, charsmax(line), "[%s] (%s) %s %s <%s>: %s", | |
| 89 | + stamp, channel, teamName, name, authid, said) | |
| 90 | + | |
| 91 | + /* ring buffer for amx_lastchat */ | |
| 92 | + copy(g_szBuffer[g_iBufHead], charsmax(g_szBuffer[]), line) | |
| 93 | + g_iBufHead = (g_iBufHead + 1) % MAX_BUFFER | |
| 94 | + | |
| 95 | + if (g_iBufCount < MAX_BUFFER) | |
| 96 | + g_iBufCount++ | |
| 97 | + | |
| 98 | + if (get_pcvar_num(g_pToFile)) | |
| 99 | + { | |
| 100 | + new day[16] | |
| 101 | + get_time("%Y-%m-%d", day, charsmax(day)) | |
| 102 | + | |
| 103 | + new file[64] | |
| 104 | + formatex(file, charsmax(file), "csb_chat_%s.log", day) | |
| 105 | + | |
| 106 | + write_file(file, line) | |
| 107 | + } | |
| 108 | +} | |
| 109 | + | |
| 110 | +public cmdLastChat(id, level, cid) | |
| 111 | +{ | |
| 112 | + if (!cmd_access(id, level, cid, 1)) | |
| 113 | + return PLUGIN_HANDLED | |
| 114 | + | |
| 115 | + if (!g_iBufCount) | |
| 116 | + { | |
| 117 | + console_print(id, "[CSB] No chat has been logged yet this map.") | |
| 118 | + return PLUGIN_HANDLED | |
| 119 | + } | |
| 120 | + | |
| 121 | + console_print(id, "----- CSB Chat Logger: last %d line(s) -----", g_iBufCount) | |
| 122 | + | |
| 123 | + /* walk the ring buffer oldest -> newest */ | |
| 124 | + new start = (g_iBufHead - g_iBufCount + MAX_BUFFER) % MAX_BUFFER | |
| 125 | + | |
| 126 | + for (new i = 0; i < g_iBufCount; i++) | |
| 127 | + { | |
| 128 | + new idx = (start + i) % MAX_BUFFER | |
| 129 | + console_print(id, "%s", g_szBuffer[idx]) | |
| 130 | + } | |
| 131 | + | |
| 132 | + console_print(id, "--------------------------------------------") | |
| 133 | + return PLUGIN_HANDLED | |
| 134 | +} |
csb.json
A
| @@ -0,0 +1,42 @@ | ||
| 1 | +{ | |
| 2 | + "name": "CSB Chat Logger", | |
| 3 | + "category": "admin", | |
| 4 | + "tags": "chat, logs, audit", | |
| 5 | + "image": "", | |
| 6 | + "original_author": "", | |
| 7 | + "original_url": "", | |
| 8 | + "license": "GPL-3.0", | |
| 9 | + "title": "CSB Chat Logger", | |
| 10 | + "short_desc": "Logs every say / say_team line with name, SteamID, team and time to a per-day file; amx_lastchat dumps recent lines.", | |
| 11 | + "version": "1.0.0", | |
| 12 | + "amxx_min": "1.9", | |
| 13 | + "amxx_compile_default": "1.9", | |
| 14 | + "rehlds_ok": true, | |
| 15 | + "hlds_ok": true, | |
| 16 | + "regamedll_required": false, | |
| 17 | + "metamod_flavor": "any", | |
| 18 | + "reapi_required": false, | |
| 19 | + "modules": "", | |
| 20 | + "install_notes": "1. Put csb_chat_logger.amxx in addons/amxmodx/plugins/\n2. Add it to addons/amxmodx/configs/plugins.ini\n3. Change map\n4. Files appear as csb_chat_YYYY-MM-DD.log in addons/amxmodx/logs/", | |
| 21 | + "known_conflicts": "", | |
| 22 | + "cvars": [ | |
| 23 | + { | |
| 24 | + "name": "csb_chatlog_enabled", | |
| 25 | + "default": "1", | |
| 26 | + "description": "Enable or disable chat capture." | |
| 27 | + }, | |
| 28 | + { | |
| 29 | + "name": "csb_chatlog_tofile", | |
| 30 | + "default": "1", | |
| 31 | + "description": "Also append every line to a per-day log file (0 = memory buffer only)." | |
| 32 | + } | |
| 33 | + ], | |
| 34 | + "commands": [ | |
| 35 | + { | |
| 36 | + "name": "amx_lastchat", | |
| 37 | + "access": "c (ADMIN_KICK)", | |
| 38 | + "description": "Dump the last chat lines to your console." | |
| 39 | + } | |
| 40 | + ], | |
| 41 | + "main": "addons/amxmodx/scripting/csb_chat_logger.sma" | |
| 42 | +} | |
| 0 | 43 |









