Initial release 1.0.0
Browse Source1.0.0 - Initial release.
4 changed files
with 266 additions and 0 deletions
A
CHANGELOG.md
+3 -0
A
README.md
+1 -0
A
addons/amxmodx/scripting/csb_daily_top.sma
+225 -0
A
csb.json
+37 -0
CHANGELOG.md
A
| @@ -0,0 +1,3 @@ | ||
| 1 | +## 1.0.0 (2025-09-06) | |
| 2 | + | |
| 3 | +1.0.0 - Initial release. |
README.md
A
| @@ -0,0 +1 @@ | ||
| 1 | +<p><strong>CSB Daily Top</strong> keeps a kill counter per SteamID that only counts kills from the current server day: the date stamp is stored next to the counter in nVault, so the board resets automatically at midnight. At map end the daily top 3 are announced, and if the <a href="/plugins/csb-credits-shop">CSB Credits Shop</a> is installed the day's winner receives a configurable credit reward (<code>csb_daily_reward</code>). <code>/dailytop</code> shows your count and the current top 10.</p><h2>Features</h2><ul><li>Automatic midnight reset via date-stamped vault entries.</li><li>Daily top 3 announcement at map end.</li><li>Optional credit reward through the CSB credits native.</li></ul><h2>Installation</h2><ol><li>Enable the <code>nvault</code> module.</li><li>Compile, install, add to <code>plugins.ini</code>, change map.</li></ol> |
addons/amxmodx/scripting/csb_daily_top.sma
A
| @@ -0,0 +1,225 @@ | ||
| 1 | +/* | |
| 2 | + * CSB Daily Top | |
| 3 | + * Copyright (C) 2026 counter-strike-boost.com | |
| 4 | + * | |
| 5 | + * Keeps a per-SteamID kill counter that only counts kills made on the current | |
| 6 | + * server day. The date stamp is stored with the counter in nVault, so the | |
| 7 | + * counter resets automatically at server midnight. At map end the daily top 3 | |
| 8 | + * are announced, and if the CSB credits shop is installed the day's winner is | |
| 9 | + * handed a configurable credit reward. | |
| 10 | + * | |
| 11 | + * This program is free software: you can redistribute it and/or modify it under | |
| 12 | + * the terms of the GNU General Public License as published by the Free Software | |
| 13 | + * Foundation, either version 3 of the License, or (at your option) any later | |
| 14 | + * version. It is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 16 | + * FOR A PARTICULAR PURPOSE. See <https://www.gnu.org/licenses/> for details. | |
| 17 | + */ | |
| 18 | + | |
| 19 | +#include <amxmodx> | |
| 20 | +#include <nvault> | |
| 21 | + | |
| 22 | +/* provided by CSB Credits Shop; called only when that plugin is loaded */ | |
| 23 | +native csb_add_credits(id, amount); | |
| 24 | + | |
| 25 | +new const PLUGIN[] = "CSB Daily Top" | |
| 26 | +new const VERSION[] = "1.0.0" | |
| 27 | +new const AUTHOR[] = "counter-strike-boost.com" | |
| 28 | + | |
| 29 | +new g_iKills[33] | |
| 30 | +new g_iVault | |
| 31 | +new g_pReward | |
| 32 | + | |
| 33 | +public plugin_init() | |
| 34 | +{ | |
| 35 | + register_plugin(PLUGIN, VERSION, AUTHOR) | |
| 36 | + | |
| 37 | + g_pReward = register_cvar("csb_daily_reward", "0") | |
| 38 | + | |
| 39 | + register_event("DeathMsg", "onDeath", "a") | |
| 40 | + | |
| 41 | + register_clcmd("say /dailytop", "cmdTop") | |
| 42 | + register_clcmd("say_team /dailytop", "cmdTop") | |
| 43 | + | |
| 44 | + g_iVault = nvault_open("csb_dailytop") | |
| 45 | +} | |
| 46 | + | |
| 47 | +public plugin_end() | |
| 48 | +{ | |
| 49 | + announceTop() | |
| 50 | + | |
| 51 | + if (g_iVault != -1) | |
| 52 | + nvault_close(g_iVault) | |
| 53 | +} | |
| 54 | + | |
| 55 | +public client_putinserver(id) | |
| 56 | +{ | |
| 57 | + g_iKills[id] = 0 | |
| 58 | + loadPlayer(id) | |
| 59 | +} | |
| 60 | + | |
| 61 | +public client_disconnect(id) | |
| 62 | +{ | |
| 63 | + savePlayer(id) | |
| 64 | +} | |
| 65 | + | |
| 66 | +public onDeath() | |
| 67 | +{ | |
| 68 | + new killer = read_data(1) | |
| 69 | + new victim = read_data(2) | |
| 70 | + | |
| 71 | + if (killer < 1 || killer > 32 || killer == victim) | |
| 72 | + return | |
| 73 | + | |
| 74 | + if (get_user_team(killer) == get_user_team(victim)) | |
| 75 | + return | |
| 76 | + | |
| 77 | + g_iKills[killer]++ | |
| 78 | + savePlayer(killer) | |
| 79 | +} | |
| 80 | + | |
| 81 | +public cmdTop(id) | |
| 82 | +{ | |
| 83 | + client_print(id, print_chat, "[CSB] Your kills today: %d", g_iKills[id]) | |
| 84 | + printTop(id) | |
| 85 | + return PLUGIN_HANDLED | |
| 86 | +} | |
| 87 | + | |
| 88 | +printTop(id) | |
| 89 | +{ | |
| 90 | + new ids[33], scores[33], count = 0 | |
| 91 | + | |
| 92 | + for (new p = 1; p <= 32; p++) | |
| 93 | + { | |
| 94 | + if (!is_user_connected(p)) | |
| 95 | + continue | |
| 96 | + | |
| 97 | + ids[count] = p | |
| 98 | + scores[count] = g_iKills[p] | |
| 99 | + count++ | |
| 100 | + } | |
| 101 | + | |
| 102 | + sortDesc(ids, scores, count) | |
| 103 | + | |
| 104 | + client_print(id, print_console, "----- CSB Daily Top -----") | |
| 105 | + | |
| 106 | + for (new i = 0; i < count && i < 10; i++) | |
| 107 | + { | |
| 108 | + new name[32] | |
| 109 | + get_user_name(ids[i], name, charsmax(name)) | |
| 110 | + client_print(id, print_console, "%2d. %-24s %d", i + 1, name, scores[i]) | |
| 111 | + } | |
| 112 | +} | |
| 113 | + | |
| 114 | +announceTop() | |
| 115 | +{ | |
| 116 | + new ids[33], scores[33], count = 0 | |
| 117 | + | |
| 118 | + for (new p = 1; p <= 32; p++) | |
| 119 | + { | |
| 120 | + if (!is_user_connected(p)) | |
| 121 | + continue | |
| 122 | + | |
| 123 | + ids[count] = p | |
| 124 | + scores[count] = g_iKills[p] | |
| 125 | + count++ | |
| 126 | + } | |
| 127 | + | |
| 128 | + if (count < 1) | |
| 129 | + return | |
| 130 | + | |
| 131 | + sortDesc(ids, scores, count) | |
| 132 | + | |
| 133 | + if (scores[0] < 1) | |
| 134 | + return | |
| 135 | + | |
| 136 | + client_print(0, print_chat, "[CSB] Daily top 3 for today:") | |
| 137 | + | |
| 138 | + for (new i = 0; i < count && i < 3; i++) | |
| 139 | + { | |
| 140 | + new name[32] | |
| 141 | + get_user_name(ids[i], name, charsmax(name)) | |
| 142 | + client_print(0, print_chat, "[CSB] #%d %s - %d kills", i + 1, name, scores[i]) | |
| 143 | + } | |
| 144 | + | |
| 145 | + /* hand the winner a credit reward if the shop is installed */ | |
| 146 | + new reward = get_pcvar_num(g_pReward) | |
| 147 | + | |
| 148 | + if (reward > 0 && is_plugin_loaded("csb_credits_shop.amxx", true) != -1) | |
| 149 | + { | |
| 150 | + csb_add_credits(ids[0], reward) | |
| 151 | + | |
| 152 | + new name[32] | |
| 153 | + get_user_name(ids[0], name, charsmax(name)) | |
| 154 | + client_print(0, print_chat, "[CSB] %s earns %d credits for topping the day!", name, reward) | |
| 155 | + } | |
| 156 | +} | |
| 157 | + | |
| 158 | +sortDesc(ids[], scores[], count) | |
| 159 | +{ | |
| 160 | + for (new i = 0; i < count - 1; i++) | |
| 161 | + { | |
| 162 | + for (new j = i + 1; j < count; j++) | |
| 163 | + { | |
| 164 | + if (scores[j] > scores[i]) | |
| 165 | + { | |
| 166 | + new ts = scores[i] | |
| 167 | + scores[i] = scores[j] | |
| 168 | + scores[j] = ts | |
| 169 | + | |
| 170 | + new ti = ids[i] | |
| 171 | + ids[i] = ids[j] | |
| 172 | + ids[j] = ti | |
| 173 | + } | |
| 174 | + } | |
| 175 | + } | |
| 176 | +} | |
| 177 | + | |
| 178 | +todayStr(out[], len) | |
| 179 | +{ | |
| 180 | + get_time("%Y%m%d", out, len) | |
| 181 | +} | |
| 182 | + | |
| 183 | +loadPlayer(id) | |
| 184 | +{ | |
| 185 | + if (g_iVault == -1) | |
| 186 | + return | |
| 187 | + | |
| 188 | + new auth[36], key[48], data[32] | |
| 189 | + get_user_authid(id, auth, charsmax(auth)) | |
| 190 | + | |
| 191 | + if (auth[0] == 0 || equal(auth, "STEAM_ID_PENDING")) | |
| 192 | + return | |
| 193 | + | |
| 194 | + formatex(key, charsmax(key), "daily_%s", auth) | |
| 195 | + | |
| 196 | + if (nvault_get(g_iVault, key, data, charsmax(data)) < 1) | |
| 197 | + return | |
| 198 | + | |
| 199 | + new sdate[12], skills[12] | |
| 200 | + parse(data, sdate, charsmax(sdate), skills, charsmax(skills)) | |
| 201 | + | |
| 202 | + new today[12] | |
| 203 | + todayStr(today, charsmax(today)) | |
| 204 | + | |
| 205 | + if (equal(sdate, today)) | |
| 206 | + g_iKills[id] = str_to_num(skills) | |
| 207 | +} | |
| 208 | + | |
| 209 | +savePlayer(id) | |
| 210 | +{ | |
| 211 | + if (g_iVault == -1) | |
| 212 | + return | |
| 213 | + | |
| 214 | + new auth[36], key[48], data[32], today[12] | |
| 215 | + get_user_authid(id, auth, charsmax(auth)) | |
| 216 | + | |
| 217 | + if (auth[0] == 0 || equal(auth, "STEAM_ID_PENDING")) | |
| 218 | + return | |
| 219 | + | |
| 220 | + todayStr(today, charsmax(today)) | |
| 221 | + formatex(key, charsmax(key), "daily_%s", auth) | |
| 222 | + formatex(data, charsmax(data), "%s %d", today, g_iKills[id]) | |
| 223 | + | |
| 224 | + nvault_set(g_iVault, key, data) | |
| 225 | +} |
csb.json
A
| @@ -0,0 +1,37 @@ | ||
| 1 | +{ | |
| 2 | + "name": "CSB Daily Top", | |
| 3 | + "category": "stats", | |
| 4 | + "tags": "daily, top, reset", | |
| 5 | + "image": "", | |
| 6 | + "original_author": "", | |
| 7 | + "original_url": "", | |
| 8 | + "license": "GPL-3.0", | |
| 9 | + "title": "CSB Daily Top", | |
| 10 | + "short_desc": "Per-day kill counter per SteamID that resets at server midnight, with a daily top 3 announced at map end.", | |
| 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": "nvault", | |
| 20 | + "install_notes": "1. Enable the nvault module 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_daily_reward", | |
| 25 | + "default": "0", | |
| 26 | + "description": "Credits paid to the day's winner (requires CSB Credits Shop; 0 disables)." | |
| 27 | + } | |
| 28 | + ], | |
| 29 | + "commands": [ | |
| 30 | + { | |
| 31 | + "name": "say /dailytop", | |
| 32 | + "access": "", | |
| 33 | + "description": "Show your kills today and the current top 10." | |
| 34 | + } | |
| 35 | + ], | |
| 36 | + "main": "addons/amxmodx/scripting/csb_daily_top.sma" | |
| 37 | +} | |
| 0 | 38 |









