Promover servidor

Initial release 1.0.0

Browse Source
1.0.0 - Initial release.
Daemon666 committed commit f15a87901f6b8ed2f764cf73fa21c5d8b88b8c2e
4 changed files with 308 additions and 0 deletions
+3 -0 CHANGELOG.md A
@@ -0,0 +1,3 @@
1 +## 1.0.0 (2025-12-20)
2 +
3 +1.0.0 - Initial release.
+1 -0 README.md A
@@ -0,0 +1 @@
1 +<p><strong>CSB Weapon Stats</strong> keeps a per-weapon breakdown for every player: kills (from DeathMsg), headshots and damage (from Ham_TakeDamage mapped through the attacker's current weapon). Data is persisted per SteamID in nVault. <code>/wstats</code> opens a MOTD table with your numbers, your favourite weapon and the most-used weapon on the server this map.</p><h2>Features</h2><ul><li>20 weapon slots including knife and grenades.</li><li>Team damage never counted.</li><li>Server-side most-used weapon tracked per map.</li></ul><h2>Installation</h2><ol><li>Enable the <code>hamsandwich</code> and <code>nvault</code> modules.</li><li>Compile, install, add to <code>plugins.ini</code>, change map.</li></ol>
+267 -0 addons/amxmodx/scripting/csb_weapon_stats.sma A
@@ -0,0 +1,267 @@
1 +/*
2 + * CSB Weapon Stats
3 + * Copyright (C) 2026 counter-strike-boost.com
4 + *
5 + * Keeps a per-weapon breakdown for every player: kills, headshots and damage
6 + * with each weapon (tracked from DeathMsg and Ham_TakeDamage), persisted per
7 + * SteamID in nVault. /wstats opens a MOTD table with your numbers, your
8 + * favourite weapon and the most-used weapon on the server this map.
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 <hamsandwich>
20 +#include <nvault>
21 +
22 +new const PLUGIN[] = "CSB Weapon Stats"
23 +new const VERSION[] = "1.0.0"
24 +new const AUTHOR[] = "counter-strike-boost.com"
25 +
26 +#define MAX_WEAPONS 20
27 +
28 +new const g_szWeapons[][] =
29 +{
30 + "ak47", "m4a1", "awp", "deagle", "usp", "glock18", "famas", "galil",
31 + "mp5navy", "p90", "scout", "aug", "sg552", "m3", "xm1014", "m249",
32 + "knife", "grenade", "hegrenade", "flashbang"
33 +}
34 +
35 +enum WStat
36 +{
37 + WS_KILLS = 0,
38 + WS_HS,
39 + WS_DMG,
40 + WS_MAX
41 +}
42 +
43 +new g_iStats[33][MAX_WEAPONS][WS_MAX]
44 +new g_iMapKills[MAX_WEAPONS]
45 +new g_iVault
46 +
47 +public plugin_init()
48 +{
49 + register_plugin(PLUGIN, VERSION, AUTHOR)
50 +
51 + register_cvar("csb_wstats_enabled", "1")
52 +
53 + register_event("DeathMsg", "onDeath", "a")
54 + RegisterHam(Ham_TakeDamage, "player", "OnDamage", 1)
55 +
56 + register_clcmd("say /wstats", "cmdStats")
57 + register_clcmd("say_team /wstats", "cmdStats")
58 +
59 + g_iVault = nvault_open("csb_wstats")
60 +}
61 +
62 +public plugin_end()
63 +{
64 + if (g_iVault != -1)
65 + nvault_close(g_iVault)
66 +}
67 +
68 +public client_putinserver(id)
69 +{
70 + for (new w = 0; w < MAX_WEAPONS; w++)
71 + {
72 + for (new s = 0; s < WS_MAX; s++)
73 + g_iStats[id][w][s] = 0
74 + }
75 +
76 + loadPlayer(id)
77 +}
78 +
79 +public client_disconnect(id)
80 +{
81 + savePlayer(id)
82 +}
83 +
84 +public onDeath()
85 +{
86 + new killer = read_data(1)
87 + new victim = read_data(2)
88 + new hs = read_data(3)
89 + new weapon[24]
90 + read_data(4, weapon, charsmax(weapon))
91 +
92 + if (killer < 1 || killer > 32 || killer == victim)
93 + return
94 +
95 + if (get_user_team(killer) == get_user_team(victim))
96 + return
97 +
98 + new w = weaponIndex(weapon)
99 +
100 + if (w == -1)
101 + return
102 +
103 + g_iStats[killer][w][WS_KILLS]++
104 + g_iMapKills[w]++
105 +
106 + if (hs)
107 + g_iStats[killer][w][WS_HS]++
108 +}
109 +
110 +public OnDamage(victim, inflictor, attacker, Float:damage, damagetype)
111 +{
112 + if (attacker < 1 || attacker > 32 || attacker == victim)
113 + return HAM_IGNORED
114 +
115 + if (get_user_team(attacker) == get_user_team(victim))
116 + return HAM_IGNORED
117 +
118 + new wid = get_user_weapon(attacker)
119 +
120 + if (wid < 1 || wid > 29)
121 + return HAM_IGNORED
122 +
123 + new wname[24]
124 + get_weaponname(wid, wname, charsmax(wname))
125 + replace(wname, charsmax(wname), "weapon_", "")
126 +
127 + new w = weaponIndex(wname)
128 +
129 + if (w != -1)
130 + g_iStats[attacker][w][WS_DMG] += floatround(damage)
131 +
132 + return HAM_IGNORED
133 +}
134 +
135 +weaponIndex(const weapon[])
136 +{
137 + for (new w = 0; w < MAX_WEAPONS; w++)
138 + {
139 + if (equali(weapon, g_szWeapons[w]))
140 + return w
141 + }
142 +
143 + return -1
144 +}
145 +
146 +public cmdStats(id)
147 +{
148 + new motd[1536], len
149 +
150 + len = formatex(motd, charsmax(motd),
151 + "<html><body bgcolor=#101010 text=#e0e0e0><h2>CSB Weapon Stats</h2><table border=1 cellpadding=5><tr><th>Weapon</th><th>Kills</th><th>HS</th><th>Damage</th></tr>")
152 +
153 + new favW = -1, favKills = 0
154 +
155 + for (new w = 0; w < MAX_WEAPONS; w++)
156 + {
157 + if (g_iStats[id][w][WS_KILLS] < 1 && g_iStats[id][w][WS_DMG] < 1)
158 + continue
159 +
160 + len += formatex(motd[len], charsmax(motd) - len,
161 + "<tr><td>%s</td><td>%d</td><td>%d</td><td>%d</td></tr>",
162 + g_szWeapons[w], g_iStats[id][w][WS_KILLS],
163 + g_iStats[id][w][WS_HS], g_iStats[id][w][WS_DMG])
164 +
165 + if (g_iStats[id][w][WS_KILLS] > favKills)
166 + {
167 + favKills = g_iStats[id][w][WS_KILLS]
168 + favW = w
169 + }
170 + }
171 +
172 + len += formatex(motd[len], charsmax(motd) - len, "</table>")
173 +
174 + if (favW != -1)
175 + {
176 + len += formatex(motd[len], charsmax(motd) - len,
177 + "<p>Your favourite weapon: <b>%s</b> (%d kills)</p>",
178 + g_szWeapons[favW], favKills)
179 + }
180 +
181 + /* server favourite this map */
182 + new bestW = -1, bestKills = 0
183 +
184 + for (new w = 0; w < MAX_WEAPONS; w++)
185 + {
186 + if (g_iMapKills[w] > bestKills)
187 + {
188 + bestKills = g_iMapKills[w]
189 + bestW = w
190 + }
191 + }
192 +
193 + if (bestW != -1)
194 + {
195 + len += formatex(motd[len], charsmax(motd) - len,
196 + "<p>Most used weapon on the server this map: <b>%s</b> (%d kills)</p>",
197 + g_szWeapons[bestW], bestKills)
198 + }
199 +
200 + formatex(motd[len], charsmax(motd) - len, "</body></html>")
201 +
202 + show_motd(id, motd, "CSB Weapon Stats")
203 + return PLUGIN_HANDLED
204 +}
205 +
206 +loadPlayer(id)
207 +{
208 + if (g_iVault == -1)
209 + return
210 +
211 + new auth[36], key[44], data[1024]
212 + get_user_authid(id, auth, charsmax(auth))
213 +
214 + if (auth[0] == 0 || equal(auth, "STEAM_ID_PENDING"))
215 + return
216 +
217 + formatex(key, charsmax(key), "wstats_%s", auth)
218 +
219 + if (nvault_get(g_iVault, key, data, charsmax(data)) < 1)
220 + return
221 +
222 + /* flat "k hs dmg" triples per weapon */
223 + new pos = 0, w = 0, s = 0
224 + new val[16]
225 +
226 + while (w < MAX_WEAPONS)
227 + {
228 + pos = argparse(data, pos, val, charsmax(val))
229 +
230 + if (pos == -1)
231 + break
232 +
233 + g_iStats[id][w][s] = str_to_num(val)
234 +
235 + s++
236 +
237 + if (s >= WS_MAX)
238 + {
239 + s = 0
240 + w++
241 + }
242 + }
243 +}
244 +
245 +savePlayer(id)
246 +{
247 + if (g_iVault == -1)
248 + return
249 +
250 + new auth[36], key[44]
251 + get_user_authid(id, auth, charsmax(auth))
252 +
253 + if (auth[0] == 0 || equal(auth, "STEAM_ID_PENDING"))
254 + return
255 +
256 + formatex(key, charsmax(key), "wstats_%s", auth)
257 +
258 + new data[1024], len = 0
259 +
260 + for (new w = 0; w < MAX_WEAPONS; w++)
261 + {
262 + len += formatex(data[len], charsmax(data) - len, "%d %d %d ",
263 + g_iStats[id][w][WS_KILLS], g_iStats[id][w][WS_HS], g_iStats[id][w][WS_DMG])
264 + }
265 +
266 + nvault_set(g_iVault, key, data)
267 +}
+37 -0 csb.json A
@@ -0,0 +1,37 @@
1 +{
2 + "name": "CSB Weapon Stats",
3 + "category": "stats",
4 + "tags": "weapons, stats, breakdown",
5 + "image": "",
6 + "original_author": "",
7 + "original_url": "",
8 + "license": "GPL-3.0",
9 + "title": "CSB Weapon Stats",
10 + "short_desc": "Per-weapon kills, headshots and damage per player in nVault, with a /wstats MOTD and server favourite.",
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,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_wstats_enabled",
25 + "default": "1",
26 + "description": "Reserved enable toggle."
27 + }
28 + ],
29 + "commands": [
30 + {
31 + "name": "say /wstats",
32 + "access": "",
33 + "description": "Open your weapon stats MOTD."
34 + }
35 + ],
36 + "main": "addons/amxmodx/scripting/csb_weapon_stats.sma"
37 +}
0 38