Initial release 1.0.0
Browse Source1.0.0 - Initial release.
4 changed files
with 215 additions and 0 deletions
A
CHANGELOG.md
+3 -0
A
README.md
+1 -0
A
addons/amxmodx/scripting/csb_grenade_stats.sma
+174 -0
A
csb.json
+37 -0
CHANGELOG.md
A
| @@ -0,0 +1,3 @@ | ||
| 1 | +## 1.0.0 (2025-12-20) | |
| 2 | + | |
| 3 | +1.0.0 - Initial release. |
README.md
A
| @@ -0,0 +1 @@ | ||
| 1 | +<p><strong>CSB Grenade Stats</strong> tells you whether your utility actually does work. HE damage is credited when an enemy takes blast damage from a grenade entity you own, flashbangs are caught by their explosion sound and blinded enemies are detected through the ScreenFade message (only near-white fades count), and smoke throws are counted from the pin-pull sound while holding a smoke grenade. <code>/nadestats</code> shows per-round and per-map totals.</p><h2>Features</h2><ul><li>HE damage attribution via grenade entity owner.</li><li>Flash blind detection with a 2-second attribution window.</li><li>Friendly damage and self-flashes never counted.</li></ul><h2>Installation</h2><ol><li>Enable the <code>fakemeta</code> and <code>hamsandwich</code> modules.</li><li>Compile, install, add to <code>plugins.ini</code>, change map.</li></ol> |
addons/amxmodx/scripting/csb_grenade_stats.sma
A
| @@ -0,0 +1,174 @@ | ||
| 1 | +/* | |
| 2 | + * CSB Grenade Stats | |
| 3 | + * Copyright (C) 2026 counter-strike-boost.com | |
| 4 | + * | |
| 5 | + * Attributes utility usage to the thrower: HE damage is credited when a | |
| 6 | + * player takes DMG_BLAST damage from a "grenade" entity (owner read from the | |
| 7 | + * entity), flashbangs are caught by their explosion sound and blinded victims | |
| 8 | + * are detected through the ScreenFade message, and smoke throws are counted | |
| 9 | + * from the pin-pull sound while holding a smokegrenade. Totals are kept per | |
| 10 | + * round and per map; /nadestats prints your numbers. | |
| 11 | + * | |
| 12 | + * This program is free software: you can redistribute it and/or modify it under | |
| 13 | + * the terms of the GNU General Public License as published by the Free Software | |
| 14 | + * Foundation, either version 3 of the License, or (at your option) any later | |
| 15 | + * version. It is distributed in the hope that it will be useful, but WITHOUT | |
| 16 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 17 | + * FOR A PARTICULAR PURPOSE. See <https://www.gnu.org/licenses/> for details. | |
| 18 | + */ | |
| 19 | + | |
| 20 | +#include <amxmodx> | |
| 21 | +#include <fakemeta> | |
| 22 | +#include <hamsandwich> | |
| 23 | + | |
| 24 | +new const PLUGIN[] = "CSB Grenade Stats" | |
| 25 | +new const VERSION[] = "1.0.0" | |
| 26 | +new const AUTHOR[] = "counter-strike-boost.com" | |
| 27 | + | |
| 28 | +#if !defined DMG_BLAST | |
| 29 | +#define DMG_BLAST (1<<6) | |
| 30 | +#endif | |
| 31 | + | |
| 32 | +new g_iHeDmg[33] | |
| 33 | +new g_iBlinded[33] | |
| 34 | +new g_iSmokes[33] | |
| 35 | + | |
| 36 | +new g_iMapHeDmg[33] | |
| 37 | +new g_iMapBlinded[33] | |
| 38 | +new g_iMapSmokes[33] | |
| 39 | + | |
| 40 | +new g_iLastFlashOwner | |
| 41 | +new Float:g_fLastFlash | |
| 42 | + | |
| 43 | +public plugin_init() | |
| 44 | +{ | |
| 45 | + register_plugin(PLUGIN, VERSION, AUTHOR) | |
| 46 | + | |
| 47 | + register_cvar("csb_nadestats_enabled", "1") | |
| 48 | + | |
| 49 | + RegisterHam(Ham_TakeDamage, "player", "OnDamage", 1) | |
| 50 | + register_forward(FM_EmitSound, "fwEmitSound", 0) | |
| 51 | + register_message(get_user_msgid("ScreenFade"), "onScreenFade") | |
| 52 | + | |
| 53 | + register_logevent("onRoundStart", 2, "1=Round_Start") | |
| 54 | + | |
| 55 | + register_clcmd("say /nadestats", "cmdStats") | |
| 56 | + register_clcmd("say_team /nadestats", "cmdStats") | |
| 57 | +} | |
| 58 | + | |
| 59 | +public client_putinserver(id) | |
| 60 | +{ | |
| 61 | + g_iHeDmg[id] = 0 | |
| 62 | + g_iBlinded[id] = 0 | |
| 63 | + g_iSmokes[id] = 0 | |
| 64 | + g_iMapHeDmg[id] = 0 | |
| 65 | + g_iMapBlinded[id] = 0 | |
| 66 | + g_iMapSmokes[id] = 0 | |
| 67 | +} | |
| 68 | + | |
| 69 | +public onRoundStart() | |
| 70 | +{ | |
| 71 | + for (new id = 1; id <= 32; id++) | |
| 72 | + { | |
| 73 | + g_iHeDmg[id] = 0 | |
| 74 | + g_iBlinded[id] = 0 | |
| 75 | + g_iSmokes[id] = 0 | |
| 76 | + } | |
| 77 | + | |
| 78 | + g_iLastFlashOwner = 0 | |
| 79 | +} | |
| 80 | + | |
| 81 | +public OnDamage(victim, inflictor, attacker, Float:damage, damagetype) | |
| 82 | +{ | |
| 83 | + if (!(damagetype & DMG_BLAST) || damage < 1.0) | |
| 84 | + return HAM_IGNORED | |
| 85 | + | |
| 86 | + if (inflictor < 1 || victim < 1 || victim > 32) | |
| 87 | + return HAM_IGNORED | |
| 88 | + | |
| 89 | + static cls[16] | |
| 90 | + pev(inflictor, pev_classname, cls, charsmax(cls)) | |
| 91 | + | |
| 92 | + if (!equal(cls, "grenade")) | |
| 93 | + return HAM_IGNORED | |
| 94 | + | |
| 95 | + new owner = pev(inflictor, pev_owner) | |
| 96 | + | |
| 97 | + if (owner < 1 || owner > 32 || owner == victim) | |
| 98 | + return HAM_IGNORED | |
| 99 | + | |
| 100 | + if (get_user_team(owner) == get_user_team(victim)) | |
| 101 | + return HAM_IGNORED | |
| 102 | + | |
| 103 | + new dealt = floatround(damage) | |
| 104 | + g_iHeDmg[owner] += dealt | |
| 105 | + g_iMapHeDmg[owner] += dealt | |
| 106 | + | |
| 107 | + return HAM_IGNORED | |
| 108 | +} | |
| 109 | + | |
| 110 | +public fwEmitSound(ent, channel, const sample[]) | |
| 111 | +{ | |
| 112 | + /* flashbang detonation: remember who threw it and when */ | |
| 113 | + if (equal(sample, "weapons/flashbang-1.wav")) | |
| 114 | + { | |
| 115 | + g_iLastFlashOwner = pev(ent, pev_owner) | |
| 116 | + g_fLastFlash = get_gametime() | |
| 117 | + | |
| 118 | + return FMRES_IGNORED | |
| 119 | + } | |
| 120 | + | |
| 121 | + /* smoke throw: pin pull while holding the smokegrenade */ | |
| 122 | + if (equal(sample, "weapons/pinpull-1.wav")) | |
| 123 | + { | |
| 124 | + if (ent >= 1 && ent <= 32 && is_user_alive(ent) | |
| 125 | + && get_user_weapon(ent) == CSW_SMOKEGRENADE) | |
| 126 | + { | |
| 127 | + g_iSmokes[ent]++ | |
| 128 | + g_iMapSmokes[ent]++ | |
| 129 | + } | |
| 130 | + } | |
| 131 | + | |
| 132 | + return FMRES_IGNORED | |
| 133 | +} | |
| 134 | + | |
| 135 | +public onScreenFade(msgid, dest, victim) | |
| 136 | +{ | |
| 137 | + if (victim < 1 || victim > 32 || !is_user_connected(victim)) | |
| 138 | + return PLUGIN_CONTINUE | |
| 139 | + | |
| 140 | + new owner = g_iLastFlashOwner | |
| 141 | + | |
| 142 | + if (owner < 1 || owner > 32 || owner == victim) | |
| 143 | + return PLUGIN_CONTINUE | |
| 144 | + | |
| 145 | + /* only count fades right after a flashbang went off */ | |
| 146 | + if (get_gametime() - g_fLastFlash > 2.0) | |
| 147 | + return PLUGIN_CONTINUE | |
| 148 | + | |
| 149 | + if (get_user_team(owner) == get_user_team(victim)) | |
| 150 | + return PLUGIN_CONTINUE | |
| 151 | + | |
| 152 | + /* a fully blinded victim fades to near-white (arg 7 = alpha) */ | |
| 153 | + new alpha = get_msg_arg_int(7) | |
| 154 | + | |
| 155 | + if (alpha < 200) | |
| 156 | + return PLUGIN_CONTINUE | |
| 157 | + | |
| 158 | + g_iBlinded[owner]++ | |
| 159 | + g_iMapBlinded[owner]++ | |
| 160 | + | |
| 161 | + return PLUGIN_CONTINUE | |
| 162 | +} | |
| 163 | + | |
| 164 | +public cmdStats(id) | |
| 165 | +{ | |
| 166 | + client_print(id, print_console, "----- CSB Grenade Stats -----") | |
| 167 | + client_print(id, print_console, "this round: HE dmg %d enemies flashed %d smokes %d", | |
| 168 | + g_iHeDmg[id], g_iBlinded[id], g_iSmokes[id]) | |
| 169 | + client_print(id, print_console, "this map: HE dmg %d enemies flashed %d smokes %d", | |
| 170 | + g_iMapHeDmg[id], g_iMapBlinded[id], g_iMapSmokes[id]) | |
| 171 | + client_print(id, print_chat, "[CSB] Grenade stats printed to your console.") | |
| 172 | + | |
| 173 | + return PLUGIN_HANDLED | |
| 174 | +} |
csb.json
A
| @@ -0,0 +1,37 @@ | ||
| 1 | +{ | |
| 2 | + "name": "CSB Grenade Stats", | |
| 3 | + "category": "stats", | |
| 4 | + "tags": "grenades, he, flash", | |
| 5 | + "image": "", | |
| 6 | + "original_author": "", | |
| 7 | + "original_url": "", | |
| 8 | + "license": "GPL-3.0", | |
| 9 | + "title": "CSB Grenade Stats", | |
| 10 | + "short_desc": "Attributes HE damage, flash blinds and smoke throws to the thrower; per-round and per-map via /nadestats.", | |
| 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": "fakemeta,hamsandwich", | |
| 20 | + "install_notes": "1. Enable the fakemeta and hamsandwich modules in addons/amxmodx/configs/modules.ini\n2. Compile the .sma, put the .amxx in addons/amxmodx/plugins/\n3. Add it to plugins.ini and change map", | |
| 21 | + "known_conflicts": "", | |
| 22 | + "cvars": [ | |
| 23 | + { | |
| 24 | + "name": "csb_nadestats_enabled", | |
| 25 | + "default": "1", | |
| 26 | + "description": "Reserved enable toggle." | |
| 27 | + } | |
| 28 | + ], | |
| 29 | + "commands": [ | |
| 30 | + { | |
| 31 | + "name": "say /nadestats", | |
| 32 | + "access": "", | |
| 33 | + "description": "Print your grenade stats to console." | |
| 34 | + } | |
| 35 | + ], | |
| 36 | + "main": "addons/amxmodx/scripting/csb_grenade_stats.sma" | |
| 37 | +} | |
| 0 | 38 |









