Live horizontal-speed HUD (units/s) with colour thresholds and a KZ-style peak-speed line, toggled with /speed.
csb_speedometer.sma v1.0.0
1
/*
2
* CSB Speedometer
3
* Copyright (C) 2026 counter-strike-boost.com
4
*
5
* Shows the player's horizontal speed (units/s, from pev_velocity) as a live
6
* HUD number, colours it against configurable thresholds, and tracks a KZ-style
7
* peak speed for the current life. Refreshed on a short task and toggled per
8
* player with say /speed.
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 <fakemeta>
20
21
new const PLUGIN[] = "CSB Speedometer"
22
new const VERSION[] = "1.0.0"
23
new const AUTHOR[] = "counter-strike-boost.com"
24
25
new g_pEnabled, g_pMid, g_pFast, g_pShowPeak
26
new bool:g_bShow[33]
27
new Float:g_fPeak[33]
28
new g_iSync
29
30
public plugin_init()
31
{
32
register_plugin(PLUGIN, VERSION, AUTHOR)
33
34
g_pEnabled = register_cvar("csb_speed_enabled", "1")
35
g_pMid = register_cvar("csb_speed_mid", "300")
36
g_pFast = register_cvar("csb_speed_fast", "500")
37
g_pShowPeak = register_cvar("csb_speed_peak", "1")
38
39
register_clcmd("say /speed", "cmdToggle")
40
register_clcmd("say_team /speed", "cmdToggle")
41
42
register_event("ResetHUD", "eventSpawn", "b")
43
44
g_iSync = CreateHudSyncObj()
45
set_task(0.2, "taskSpeed", 0, _, _, "b")
46
}
47
48
public client_putinserver(id)
49
{
50
g_bShow[id] = true
51
g_fPeak[id] = 0.0
52
}
53
54
public cmdToggle(id)
55
{
56
g_bShow[id] = !g_bShow[id]
57
client_print(id, print_chat, "[CSB] Speedometer %s.", g_bShow[id] ? "enabled" : "disabled")
58
return PLUGIN_HANDLED
59
}
60
61
public eventSpawn(id)
62
{
63
g_fPeak[id] = 0.0
64
}
65
66
public taskSpeed()
67
{
68
if (!get_pcvar_num(g_pEnabled))
69
return
70
71
new mid = get_pcvar_num(g_pMid)
72
new fast = get_pcvar_num(g_pFast)
73
new bool:peak = get_pcvar_num(g_pShowPeak) != 0
74
75
new players[32], num, id
76
get_players(players, num, "a")
77
78
for (new i = 0; i < num; i++)
79
{
80
id = players[i]
81
82
if (!g_bShow[id])
83
continue
84
85
static Float:fVel[3]
86
pev(id, pev_velocity, fVel)
87
88
new Float:speed = floatsqroot(fVel[0] * fVel[0] + fVel[1] * fVel[1])
89
new iSpeed = floatround(speed)
90
91
if (speed > g_fPeak[id])
92
g_fPeak[id] = speed
93
94
new r = 0, g = 255, b = 0
95
96
if (iSpeed >= fast)
97
{
98
r = 255
99
g = 40
100
b = 40
101
}
102
else if (iSpeed >= mid)
103
{
104
r = 255
105
g = 200
106
b = 0
107
}
108
109
set_hudmessage(r, g, b, -1.0, 0.82, 0, 0.0, 0.25, 0.0, 0.0, -1)
110
111
if (peak)
112
ShowSyncHudMsg(id, g_iSync, "%d u/s^nPeak: %d u/s", iSpeed, floatround(g_fPeak[id]))
113
else
114
ShowSyncHudMsg(id, g_iSync, "%d u/s", iSpeed)
115
}
116
}
117









