/* * CSB Rank Stats * Copyright (C) 2026 counter-strike-boost.com * * /rank and /stats print the caller's kills, deaths, K/D, headshot percentage, * accuracy, playtime and ladder position in coloured chat. /statsme dumps a * per-weapon breakdown to the game console. All figures come from the CSX * ranked storage (the csx module). * * Inspired by the well-known "StatsX" plugin for AMX Mod X. 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 Rank Stats" new const VERSION[] = "1.0.0" new const AUTHOR[] = "counter-strike-boost.com" new g_pEnabled public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) g_pEnabled = register_cvar("csb_rankstats_enabled", "1") register_clcmd("say /rank", "cmdRank") register_clcmd("say_team /rank", "cmdRank") register_clcmd("say /stats", "cmdRank") register_clcmd("say_team /stats", "cmdRank") register_clcmd("say /statsme", "cmdStatsMe") register_clcmd("say_team /statsme", "cmdStatsMe") register_clcmd("csb_rank", "cmdRank") } public cmdRank(id) { if (!get_pcvar_num(g_pEnabled)) return PLUGIN_HANDLED new stats[8], body[8] new rank = get_user_stats(id, stats, body) new total = get_statsnum() if (rank <= 0) { client_print_color(id, print_team_default, "^4[CSB]^1 You are not ranked yet - get some frags first.") return PLUGIN_HANDLED } new Float:kd = stats[1] ? float(stats[0]) / float(stats[1]) : float(stats[0]) new acc = stats[4] ? (stats[5] * 100) / stats[4] : 0 new hspct = stats[0] ? (stats[2] * 100) / stats[0] : 0 new mins = get_user_time(id, 1) / 60 client_print_color(id, print_team_default, "^4[CSB]^1 Rank^3 %d^1 of^3 %d^1 - Kills:^3 %d^1 Deaths:^3 %d^1 K/D:^3 %.2f", rank, total, stats[0], stats[1], kd) client_print_color(id, print_team_default, "^4[CSB]^1 Headshots:^3 %d^1 (%d%%) Accuracy:^3 %d%%^1 Playtime:^3 %d^1 min", stats[2], hspct, acc, mins) return PLUGIN_HANDLED } public cmdStatsMe(id) { if (!get_pcvar_num(g_pEnabled)) return PLUGIN_HANDLED new stats[8], body[8], wname[24] new maxw = xmod_get_maxweapons() console_print(id, "^n==================== CSB Weapon Stats ====================") console_print(id, "%-16s %6s %6s %6s %6s %6s %8s", "Weapon", "Kills", "Deaths", "Shots", "Hits", "HS", "Damage") console_print(id, "----------------------------------------------------------") new any = 0 for (new w = 1; w < maxw; w++) { if (!get_user_wstats(id, w, stats, body)) continue if (stats[0] == 0 && stats[4] == 0) continue xmod_get_wpnname(w, wname, charsmax(wname)) console_print(id, "%-16s %6d %6d %6d %6d %6d %8d", wname, stats[0], stats[1], stats[4], stats[5], stats[2], stats[6]) any++ } if (!any) console_print(id, "(no per-weapon statistics recorded yet)") console_print(id, "==========================================================") client_print_color(id, print_team_default, "^4[CSB]^1 Your per-weapon stats were printed to the console (~).") return PLUGIN_HANDLED }