/* * CSB Damage HUD * Copyright (C) 2026 counter-strike-boost.com * * Shows a short-lived floating damage number to the attacker every time a hit * lands (read from Ham_TakeDamage) and keeps a running total of the damage * dealt to the current victim in the corner of the screen. Each player can * turn it off for themselves with /dmghud. * * Inspired by the "Damage HUD" plugin by Alka. This is an independent GPL * re-implementation; no original code is reused. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) * any later version. It is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details: . */ #include #include new const PLUGIN[] = "CSB Damage HUD" new const VERSION[] = "1.0.0" new const AUTHOR[] = "counter-strike-boost.com" new bool:g_bEnabled[33] = { true, ... } new g_iLastVictim[33] new g_iRunningTotal[33] new g_pEnabled public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) g_pEnabled = register_cvar("csb_dmghud_enabled", "1") RegisterHam(Ham_TakeDamage, "player", "fwTakeDamage") register_event("HLTV", "eNewRound", "a", "1=0", "2=0") register_clcmd("say /dmghud", "cmdToggle") register_clcmd("say_team /dmghud", "cmdToggle") register_clcmd("csb_dmghud", "cmdToggle") } public client_putinserver(id) { g_bEnabled[id] = true g_iLastVictim[id] = 0 g_iRunningTotal[id] = 0 } public eNewRound() { for (new i = 1; i <= 32; i++) { g_iLastVictim[i] = 0 g_iRunningTotal[i] = 0 } } public cmdToggle(id) { g_bEnabled[id] = !g_bEnabled[id] client_print(id, print_chat, "[CSB] Floating damage numbers are now %s.", g_bEnabled[id] ? "ON" : "OFF") return PLUGIN_HANDLED } public fwTakeDamage(victim, inflictor, attacker, Float:damage, damagebits) { if (!get_pcvar_num(g_pEnabled)) return HAM_IGNORED if (attacker < 1 || attacker > 32 || victim < 1 || victim > 32 || attacker == victim) return HAM_IGNORED if (!is_user_connected(attacker) || !g_bEnabled[attacker]) return HAM_IGNORED new dmg = floatround(damage) if (dmg <= 0) return HAM_IGNORED /* running total resets when the attacker switches to a new victim */ if (g_iLastVictim[attacker] != victim) { g_iLastVictim[attacker] = victim g_iRunningTotal[attacker] = 0 } g_iRunningTotal[attacker] += dmg /* floating hit number, slightly randomised so successive hits do not overlap */ new Float:x = 0.45 + random_float(-0.06, 0.06) new Float:y = 0.48 + random_float(-0.05, 0.05) set_hudmessage(255, 40, 40, x, y, 2, 0.02, 0.7, 0.02, 0.1, 4) show_hudmessage(attacker, "-%d", dmg) /* running total to the victim in the corner */ new vname[32] get_user_name(victim, vname, charsmax(vname)) set_hudmessage(255, 190, 40, 0.72, 0.20, 0, 0.0, 1.2, 0.05, 0.1, 5) show_hudmessage(attacker, "%s^n%d dmg total", vname, g_iRunningTotal[attacker]) return HAM_IGNORED }