Initial release 1.0.0
Browse Source1.0.0 - Initial release.
4 changed files
with 236 additions and 0 deletions
A
CHANGELOG.md
+3 -0
A
README.md
+1 -0
A
addons/amxmodx/scripting/csb_session_stats.sma
+190 -0
A
csb.json
+42 -0
CHANGELOG.md
A
| @@ -0,0 +1,3 @@ | ||
| 1 | +## 1.0.0 (2026-02-08) | |
| 2 | + | |
| 3 | +1.0.0 - Initial release. |
README.md
A
| @@ -0,0 +1 @@ | ||
| 1 | +<p><strong>CSB Session Stats</strong> is a lightweight, no-database session tracker. It holds everything in memory per player slot and clears it on disconnect, so there is nothing to install, no vault, no MySQL. <code>say /session</code> prints your kills, deaths, K/D, headshots, damage dealt, rounds won, best killstreak and minutes played; a short version can be shown to everyone at the end of each round.</p><h2>How the numbers are measured</h2><ul><li>Kills, deaths, headshots and killstreak from the <code>DeathMsg</code> event.</li><li>Damage dealt attributed to the attacker via a <code>Ham_TakeDamage</code> hook (hamsandwich).</li><li>Rounds won detected from the round-win audio (<code>SendAudio</code>) and credited to the winning team's players.</li><li>Time played from the moment the player entered the server.</li></ul><h2>Installation</h2><ol><li>Compile <code>csb_session_stats.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>Set <code>csb_session_roundline 0</code> if you do not want the short per-round chat summary. On disconnect a one-line summary is written to the AMXX log.</p> |
addons/amxmodx/scripting/csb_session_stats.sma
A
| @@ -0,0 +1,190 @@ | ||
| 1 | +/* | |
| 2 | + * CSB Session Stats | |
| 3 | + * Copyright (C) 2026 counter-strike-boost.com | |
| 4 | + * | |
| 5 | + * Keeps a per-slot, in-memory summary of the current session: kills, deaths, | |
| 6 | + * headshots, damage dealt, rounds won, time played and best killstreak. Shows | |
| 7 | + * it on say /session, on disconnect (to the AMXX log) and a short line at round | |
| 8 | + * end. Nothing is persisted - it resets when the player leaves. | |
| 9 | + * | |
| 10 | + * This program is free software: you can redistribute it and/or modify it under | |
| 11 | + * the terms of the GNU General Public License as published by the Free Software | |
| 12 | + * Foundation, either version 3 of the License, or (at your option) any later | |
| 13 | + * version. It is distributed in the hope that it will be useful, but WITHOUT | |
| 14 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 15 | + * FOR A PARTICULAR PURPOSE. See <https://www.gnu.org/licenses/> for details. | |
| 16 | + */ | |
| 17 | + | |
| 18 | +#include <amxmodx> | |
| 19 | +#include <amxmisc> | |
| 20 | +#include <hamsandwich> | |
| 21 | + | |
| 22 | +new const PLUGIN[] = "CSB Session Stats" | |
| 23 | +new const VERSION[] = "1.0.0" | |
| 24 | +new const AUTHOR[] = "counter-strike-boost.com" | |
| 25 | + | |
| 26 | +new g_iKills[33] | |
| 27 | +new g_iDeaths[33] | |
| 28 | +new g_iHs[33] | |
| 29 | +new g_iDamage[33] | |
| 30 | +new g_iRoundsWon[33] | |
| 31 | +new g_iStreak[33] | |
| 32 | +new g_iBestStreak[33] | |
| 33 | +new g_iJoinTime[33] | |
| 34 | + | |
| 35 | +new g_pEnabled, g_pRoundLine | |
| 36 | + | |
| 37 | +public plugin_init() | |
| 38 | +{ | |
| 39 | + register_plugin(PLUGIN, VERSION, AUTHOR) | |
| 40 | + | |
| 41 | + g_pEnabled = register_cvar("csb_session_enabled", "1") | |
| 42 | + g_pRoundLine = register_cvar("csb_session_roundline", "1") | |
| 43 | + | |
| 44 | + register_event("DeathMsg", "eventDeath", "a", "1>0") | |
| 45 | + register_event("SendAudio", "eventWin", "a") | |
| 46 | + register_logevent("eventRoundEnd", 2, "1=Round_End") | |
| 47 | + | |
| 48 | + RegisterHam(Ham_TakeDamage, "player", "hamTakeDamage") | |
| 49 | + | |
| 50 | + register_clcmd("say /session", "cmdSession") | |
| 51 | + register_clcmd("say_team /session", "cmdSession") | |
| 52 | +} | |
| 53 | + | |
| 54 | +public client_putinserver(id) | |
| 55 | +{ | |
| 56 | + resetPlayer(id) | |
| 57 | + g_iJoinTime[id] = get_systime() | |
| 58 | +} | |
| 59 | + | |
| 60 | +public client_disconnected(id) | |
| 61 | +{ | |
| 62 | + if (g_iKills[id] || g_iDeaths[id]) | |
| 63 | + { | |
| 64 | + new name[32] | |
| 65 | + get_user_name(id, name, charsmax(name)) | |
| 66 | + log_amx("[CSB Session] %s left - %d kills, %d deaths, %d hs, %d dmg, best streak %d", | |
| 67 | + name, g_iKills[id], g_iDeaths[id], g_iHs[id], g_iDamage[id], g_iBestStreak[id]) | |
| 68 | + } | |
| 69 | + | |
| 70 | + resetPlayer(id) | |
| 71 | +} | |
| 72 | + | |
| 73 | +resetPlayer(id) | |
| 74 | +{ | |
| 75 | + g_iKills[id] = 0 | |
| 76 | + g_iDeaths[id] = 0 | |
| 77 | + g_iHs[id] = 0 | |
| 78 | + g_iDamage[id] = 0 | |
| 79 | + g_iRoundsWon[id] = 0 | |
| 80 | + g_iStreak[id] = 0 | |
| 81 | + g_iBestStreak[id] = 0 | |
| 82 | + g_iJoinTime[id] = get_systime() | |
| 83 | +} | |
| 84 | + | |
| 85 | +public hamTakeDamage(victim, inflictor, attacker, Float:damage, damagebits) | |
| 86 | +{ | |
| 87 | + if (attacker < 1 || attacker > 32 || attacker == victim) | |
| 88 | + return HAM_IGNORED | |
| 89 | + | |
| 90 | + g_iDamage[attacker] += floatround(damage) | |
| 91 | + return HAM_IGNORED | |
| 92 | +} | |
| 93 | + | |
| 94 | +public eventDeath() | |
| 95 | +{ | |
| 96 | + new killer = read_data(1) | |
| 97 | + new victim = read_data(2) | |
| 98 | + new hs = read_data(3) | |
| 99 | + | |
| 100 | + if (victim >= 1 && victim <= 32) | |
| 101 | + { | |
| 102 | + g_iDeaths[victim]++ | |
| 103 | + g_iStreak[victim] = 0 | |
| 104 | + } | |
| 105 | + | |
| 106 | + if (killer >= 1 && killer <= 32 && killer != victim) | |
| 107 | + { | |
| 108 | + g_iKills[killer]++ | |
| 109 | + g_iStreak[killer]++ | |
| 110 | + | |
| 111 | + if (g_iStreak[killer] > g_iBestStreak[killer]) | |
| 112 | + g_iBestStreak[killer] = g_iStreak[killer] | |
| 113 | + | |
| 114 | + if (hs) | |
| 115 | + g_iHs[killer]++ | |
| 116 | + } | |
| 117 | +} | |
| 118 | + | |
| 119 | +public eventWin() | |
| 120 | +{ | |
| 121 | + new audio[48] | |
| 122 | + read_data(2, audio, charsmax(audio)) | |
| 123 | + | |
| 124 | + new winTeam = 0 | |
| 125 | + | |
| 126 | + if (containi(audio, "terwin") != -1) | |
| 127 | + winTeam = 1 | |
| 128 | + else if (containi(audio, "ctwin") != -1) | |
| 129 | + winTeam = 2 | |
| 130 | + | |
| 131 | + if (!winTeam) | |
| 132 | + return | |
| 133 | + | |
| 134 | + new players[32], num, pid | |
| 135 | + get_players(players, num, "ae") | |
| 136 | + | |
| 137 | + for (new i = 0; i < num; i++) | |
| 138 | + { | |
| 139 | + pid = players[i] | |
| 140 | + | |
| 141 | + if (get_user_team(pid) == winTeam) | |
| 142 | + g_iRoundsWon[pid]++ | |
| 143 | + } | |
| 144 | +} | |
| 145 | + | |
| 146 | +public eventRoundEnd() | |
| 147 | +{ | |
| 148 | + if (!get_pcvar_num(g_pRoundLine)) | |
| 149 | + return | |
| 150 | + | |
| 151 | + new players[32], num, pid | |
| 152 | + get_players(players, num, "c") | |
| 153 | + | |
| 154 | + for (new i = 0; i < num; i++) | |
| 155 | + { | |
| 156 | + pid = players[i] | |
| 157 | + | |
| 158 | + if (g_iKills[pid] || g_iDeaths[pid]) | |
| 159 | + printSummary(pid, pid, true) | |
| 160 | + } | |
| 161 | +} | |
| 162 | + | |
| 163 | +public cmdSession(id) | |
| 164 | +{ | |
| 165 | + if (!get_pcvar_num(g_pEnabled)) | |
| 166 | + return PLUGIN_HANDLED | |
| 167 | + | |
| 168 | + printSummary(id, id, false) | |
| 169 | + return PLUGIN_HANDLED | |
| 170 | +} | |
| 171 | + | |
| 172 | +printSummary(id, target, bool:shortLine) | |
| 173 | +{ | |
| 174 | + new mins = (get_systime() - g_iJoinTime[target]) / 60 | |
| 175 | + | |
| 176 | + if (shortLine) | |
| 177 | + { | |
| 178 | + client_print(id, print_chat, "[CSB] Session: %d-%d, %d hs, best streak %d.", | |
| 179 | + g_iKills[target], g_iDeaths[target], g_iHs[target], g_iBestStreak[target]) | |
| 180 | + return | |
| 181 | + } | |
| 182 | + | |
| 183 | + new Float:kdr = g_iDeaths[target] ? float(g_iKills[target]) / float(g_iDeaths[target]) : float(g_iKills[target]) | |
| 184 | + | |
| 185 | + client_print(id, print_chat, "[CSB] --- Your session so far ---") | |
| 186 | + client_print(id, print_chat, "[CSB] Kills: %d | Deaths: %d | K/D: %.2f | Headshots: %d", | |
| 187 | + g_iKills[target], g_iDeaths[target], kdr, g_iHs[target]) | |
| 188 | + client_print(id, print_chat, "[CSB] Damage: %d | Rounds won: %d | Best streak: %d | Time: %d min", | |
| 189 | + g_iDamage[target], g_iRoundsWon[target], g_iBestStreak[target], mins) | |
| 190 | +} |
csb.json
A
| @@ -0,0 +1,42 @@ | ||
| 1 | +{ | |
| 2 | + "name": "CSB Session Stats", | |
| 3 | + "category": "stats", | |
| 4 | + "tags": "session, summary, stats", | |
| 5 | + "image": "", | |
| 6 | + "original_author": "", | |
| 7 | + "original_url": "", | |
| 8 | + "license": "GPL-3.0", | |
| 9 | + "title": "CSB Session Stats", | |
| 10 | + "short_desc": "In-memory session summary: kills, deaths, headshots, damage, rounds won, best streak and time played.", | |
| 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": "hamsandwich", | |
| 20 | + "install_notes": "1. Put csb_session_stats.amxx in addons/amxmodx/plugins/\n2. Add it to addons/amxmodx/configs/plugins.ini\n3. Change map", | |
| 21 | + "known_conflicts": "", | |
| 22 | + "cvars": [ | |
| 23 | + { | |
| 24 | + "name": "csb_session_enabled", | |
| 25 | + "default": "1", | |
| 26 | + "description": "Enable or disable the /session summary." | |
| 27 | + }, | |
| 28 | + { | |
| 29 | + "name": "csb_session_roundline", | |
| 30 | + "default": "1", | |
| 31 | + "description": "Show a short kills/deaths line to players at the end of each round." | |
| 32 | + } | |
| 33 | + ], | |
| 34 | + "commands": [ | |
| 35 | + { | |
| 36 | + "name": "say /session", | |
| 37 | + "access": "", | |
| 38 | + "description": "Print your current session summary." | |
| 39 | + } | |
| 40 | + ], | |
| 41 | + "main": "addons/amxmodx/scripting/csb_session_stats.sma" | |
| 42 | +} | |
| 0 | 43 |









