Initial release 1.0.0
Browse Source1.0.0 - Initial release.
4 changed files
with 292 additions and 0 deletions
A
CHANGELOG.md
+3 -0
A
README.md
+1 -0
A
addons/amxmodx/scripting/csb_admin_spectate_tools.sma
+241 -0
A
csb.json
+47 -0
CHANGELOG.md
A
| @@ -0,0 +1,3 @@ | ||
| 1 | +## 1.0.0 (2025-05-21) | |
| 2 | + | |
| 3 | +1.0.0 - Initial release. |
README.md
A
| @@ -0,0 +1 @@ | ||
| 1 | +<p><strong>CSB Spectate Tools</strong> is a small set of admin spectator helpers. <code>amx_spectate</code> opens a menu of alive players; picking one drops you into their first-person view by setting <code>pev_iuser1</code> to in-eye and <code>pev_iuser2</code> to the target. While you watch, a HUD sync object shows the target's HP, armor and current weapon, refreshed once a second so it never flickers.</p><p><code>amx_specme</code> moves you to spectator but remembers the team you were on, and <code>amx_specback</code> puts you back on it. No ReAPI, no external modules beyond fakemeta and cstrike.</p><h2>Features</h2><ul><li><code>amx_spectate</code> — menu to watch any alive player in first person.</li><li>HUD readout of the watched player's HP, armor and weapon.</li><li><code>amx_specme</code> / <code>amx_specback</code> — hop to spectator and back without losing your team.</li><li>State cleared on disconnect; the view is applied a fifth of a second after the team change so the engine has time to settle.</li></ul><h2>Installation</h2><ol><li>Compile <code>csb_admin_spectate_tools.sma</code> and copy it to <code>addons/amxmodx/plugins/</code>.</li><li>Add it to <code>plugins.ini</code> and change the map.</li></ol><p>All three commands need the <code>ADMIN_SLAY</code> flag (<code>d</code>) by default.</p> |
addons/amxmodx/scripting/csb_admin_spectate_tools.sma
A
| @@ -0,0 +1,241 @@ | ||
| 1 | +/* | |
| 2 | + * CSB Spectate Tools | |
| 3 | + * Copyright (C) 2026 counter-strike-boost.com | |
| 4 | + * | |
| 5 | + * Admin-only spectator helpers. amx_spectate opens a menu to jump straight into | |
| 6 | + * any player's first-person view (pev_iuser1 = in-eye, pev_iuser2 = target); a | |
| 7 | + * HUD shows the watched player's HP, armor and current weapon. | |
| 8 | + * amx_specme moves the admin to spectator while remembering the team, and | |
| 9 | + * amx_specback puts them back on it. | |
| 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 <amxmisc> | |
| 21 | +#include <fakemeta> | |
| 22 | +#include <cstrike> | |
| 23 | + | |
| 24 | +#define OBS_IN_EYE 4 | |
| 25 | + | |
| 26 | +new const PLUGIN[] = "CSB Spectate Tools" | |
| 27 | +new const VERSION[] = "1.0.0" | |
| 28 | +new const AUTHOR[] = "counter-strike-boost.com" | |
| 29 | + | |
| 30 | +new g_pEnabled | |
| 31 | +new g_iSyncHud | |
| 32 | +new g_iWatch[33] | |
| 33 | +new g_iSavedTeam[33] | |
| 34 | +new bool:g_bSpecMe[33] | |
| 35 | + | |
| 36 | +public plugin_init() | |
| 37 | +{ | |
| 38 | + register_plugin(PLUGIN, VERSION, AUTHOR) | |
| 39 | + | |
| 40 | + g_pEnabled = register_cvar("csb_spec_enabled", "1") | |
| 41 | + | |
| 42 | + register_concmd("amx_spectate", "cmdSpectate", ADMIN_SLAY, "- menu to watch a player in first person") | |
| 43 | + register_concmd("amx_specme", "cmdSpecMe", ADMIN_SLAY, "- move yourself to spectator, keeping your team") | |
| 44 | + register_concmd("amx_specback", "cmdSpecBack", ADMIN_SLAY, "- return to the team you had before amx_specme") | |
| 45 | + | |
| 46 | + g_iSyncHud = CreateHudSyncObj() | |
| 47 | + | |
| 48 | + set_task(1.0, "taskHud", 0, _, _, "b") | |
| 49 | +} | |
| 50 | + | |
| 51 | +public client_disconnected(id) | |
| 52 | +{ | |
| 53 | + g_iWatch[id] = 0 | |
| 54 | + g_iSavedTeam[id] = 0 | |
| 55 | + g_bSpecMe[id] = false | |
| 56 | +} | |
| 57 | + | |
| 58 | +public cmdSpectate(id, level, cid) | |
| 59 | +{ | |
| 60 | + if (!cmd_access(id, level, cid, 1)) | |
| 61 | + return PLUGIN_HANDLED | |
| 62 | + | |
| 63 | + if (!get_pcvar_num(g_pEnabled)) | |
| 64 | + { | |
| 65 | + console_print(id, "[CSB] Spectate tools are disabled (csb_spec_enabled 0).") | |
| 66 | + return PLUGIN_HANDLED | |
| 67 | + } | |
| 68 | + | |
| 69 | + showSpecMenu(id) | |
| 70 | + return PLUGIN_HANDLED | |
| 71 | +} | |
| 72 | + | |
| 73 | +showSpecMenu(id) | |
| 74 | +{ | |
| 75 | + new menu = menu_create("\ySpectate Tools^n\wPick a player to watch:", "specMenuHandler") | |
| 76 | + | |
| 77 | + new players[32], num, pid, name[32], info[8], line[64] | |
| 78 | + get_players(players, num, "a") | |
| 79 | + | |
| 80 | + for (new i = 0; i < num; i++) | |
| 81 | + { | |
| 82 | + pid = players[i] | |
| 83 | + get_user_name(pid, name, charsmax(name)) | |
| 84 | + num_to_str(pid, info, charsmax(info)) | |
| 85 | + formatex(line, charsmax(line), "%s \r[%d hp]", name, get_user_health(pid)) | |
| 86 | + menu_additem(menu, line, info, 0) | |
| 87 | + } | |
| 88 | + | |
| 89 | + if (!num) | |
| 90 | + menu_additem(menu, "\rNo alive players right now", "-1", 0) | |
| 91 | + | |
| 92 | + menu_setprop(menu, MPROP_TITLE, "\ySpectate Tools") | |
| 93 | + menu_display(id, menu, 0) | |
| 94 | +} | |
| 95 | + | |
| 96 | +public specMenuHandler(id, menu, item) | |
| 97 | +{ | |
| 98 | + if (item == MENU_EXIT || item < 0) | |
| 99 | + { | |
| 100 | + menu_destroy(menu) | |
| 101 | + return PLUGIN_HANDLED | |
| 102 | + } | |
| 103 | + | |
| 104 | + new info[8], name[32], access, callback | |
| 105 | + menu_item_getinfo(menu, item, access, info, charsmax(info), name, charsmax(name), callback) | |
| 106 | + menu_destroy(menu) | |
| 107 | + | |
| 108 | + new target = str_to_num(info) | |
| 109 | + | |
| 110 | + if (target < 1 || !is_user_connected(target)) | |
| 111 | + { | |
| 112 | + client_print(id, print_chat, "[CSB] That player is no longer available.") | |
| 113 | + return PLUGIN_HANDLED | |
| 114 | + } | |
| 115 | + | |
| 116 | + watchPlayer(id, target) | |
| 117 | + return PLUGIN_HANDLED | |
| 118 | +} | |
| 119 | + | |
| 120 | +watchPlayer(id, target) | |
| 121 | +{ | |
| 122 | + /* make sure the admin is a spectator first */ | |
| 123 | + new CsTeams:t = cs_get_user_team(id) | |
| 124 | + | |
| 125 | + if (t != CS_TEAM_SPECTATOR) | |
| 126 | + { | |
| 127 | + if (t == CS_TEAM_T || t == CS_TEAM_CT) | |
| 128 | + g_iSavedTeam[id] = _:t | |
| 129 | + | |
| 130 | + cs_set_user_team(id, CS_TEAM_SPECTATOR) | |
| 131 | + g_bSpecMe[id] = true | |
| 132 | + } | |
| 133 | + | |
| 134 | + g_iWatch[id] = target | |
| 135 | + | |
| 136 | + new tname[32] | |
| 137 | + get_user_name(target, tname, charsmax(tname)) | |
| 138 | + client_print(id, print_chat, "[CSB] Watching %s. Use amx_specback to return to your team.", tname) | |
| 139 | + | |
| 140 | + set_task(0.2, "taskApplyView", id) | |
| 141 | +} | |
| 142 | + | |
| 143 | +public taskApplyView(id) | |
| 144 | +{ | |
| 145 | + if (!is_user_connected(id)) | |
| 146 | + return | |
| 147 | + | |
| 148 | + new target = g_iWatch[id] | |
| 149 | + | |
| 150 | + if (target < 1 || !is_user_connected(target)) | |
| 151 | + return | |
| 152 | + | |
| 153 | + set_pev(id, pev_iuser1, OBS_IN_EYE) | |
| 154 | + set_pev(id, pev_iuser2, target) | |
| 155 | +} | |
| 156 | + | |
| 157 | +public cmdSpecMe(id, level, cid) | |
| 158 | +{ | |
| 159 | + if (!cmd_access(id, level, cid, 1)) | |
| 160 | + return PLUGIN_HANDLED | |
| 161 | + | |
| 162 | + new CsTeams:t = cs_get_user_team(id) | |
| 163 | + | |
| 164 | + if (t == CS_TEAM_SPECTATOR) | |
| 165 | + { | |
| 166 | + client_print(id, print_chat, "[CSB] You are already a spectator.") | |
| 167 | + return PLUGIN_HANDLED | |
| 168 | + } | |
| 169 | + | |
| 170 | + if (t == CS_TEAM_T || t == CS_TEAM_CT) | |
| 171 | + g_iSavedTeam[id] = _:t | |
| 172 | + | |
| 173 | + cs_set_user_team(id, CS_TEAM_SPECTATOR) | |
| 174 | + g_bSpecMe[id] = true | |
| 175 | + | |
| 176 | + client_print(id, print_chat, "[CSB] Moved to spectator. amx_specback returns you to your team.") | |
| 177 | + return PLUGIN_HANDLED | |
| 178 | +} | |
| 179 | + | |
| 180 | +public cmdSpecBack(id, level, cid) | |
| 181 | +{ | |
| 182 | + if (!cmd_access(id, level, cid, 1)) | |
| 183 | + return PLUGIN_HANDLED | |
| 184 | + | |
| 185 | + if (!g_bSpecMe[id] || g_iSavedTeam[id] == 0) | |
| 186 | + { | |
| 187 | + client_print(id, print_chat, "[CSB] No saved team to return to.") | |
| 188 | + return PLUGIN_HANDLED | |
| 189 | + } | |
| 190 | + | |
| 191 | + cs_set_user_team(id, CsTeams:g_iSavedTeam[id]) | |
| 192 | + | |
| 193 | + g_bSpecMe[id] = false | |
| 194 | + g_iSavedTeam[id] = 0 | |
| 195 | + g_iWatch[id] = 0 | |
| 196 | + | |
| 197 | + client_print(id, print_chat, "[CSB] Returned to your team. You will respawn next round.") | |
| 198 | + return PLUGIN_HANDLED | |
| 199 | +} | |
| 200 | + | |
| 201 | +public taskHud() | |
| 202 | +{ | |
| 203 | + new players[32], num, id, target | |
| 204 | + get_players(players, num) | |
| 205 | + | |
| 206 | + for (new i = 0; i < num; i++) | |
| 207 | + { | |
| 208 | + id = players[i] | |
| 209 | + target = g_iWatch[id] | |
| 210 | + | |
| 211 | + if (target < 1 || !is_user_connected(target) || cs_get_user_team(id) != CS_TEAM_SPECTATOR) | |
| 212 | + continue | |
| 213 | + | |
| 214 | + if (!is_user_alive(target)) | |
| 215 | + { | |
| 216 | + set_hudmessage(255, 60, 60, 0.02, 0.25, 0, 0.0, 1.1, 0.0, 0.0, -1) | |
| 217 | + ShowSyncHudMsg(id, g_iSyncHud, "Watching: (dead)") | |
| 218 | + continue | |
| 219 | + } | |
| 220 | + | |
| 221 | + new tname[32], wname[32] | |
| 222 | + get_user_name(target, tname, charsmax(tname)) | |
| 223 | + | |
| 224 | + new wid = get_user_weapon(target) | |
| 225 | + if (wid > 0) | |
| 226 | + get_weaponname(wid, wname, charsmax(wname)) | |
| 227 | + else | |
| 228 | + copy(wname, charsmax(wname), "none") | |
| 229 | + | |
| 230 | + replace(wname, charsmax(wname), "weapon_", "") | |
| 231 | + | |
| 232 | + new armor = get_user_armor(target) | |
| 233 | + | |
| 234 | + new hud[160] | |
| 235 | + formatex(hud, charsmax(hud), "%s^nHP %d AP %d^nWeapon: %s", | |
| 236 | + tname, get_user_health(target), armor, wname) | |
| 237 | + | |
| 238 | + set_hudmessage(60, 220, 255, 0.02, 0.25, 0, 0.0, 1.1, 0.0, 0.0, -1) | |
| 239 | + ShowSyncHudMsg(id, g_iSyncHud, hud) | |
| 240 | + } | |
| 241 | +} |
csb.json
A
| @@ -0,0 +1,47 @@ | ||
| 1 | +{ | |
| 2 | + "name": "CSB Spectate Tools", | |
| 3 | + "category": "admin", | |
| 4 | + "tags": "spectator, watch, admin", | |
| 5 | + "image": "", | |
| 6 | + "original_author": "", | |
| 7 | + "original_url": "", | |
| 8 | + "license": "GPL-3.0", | |
| 9 | + "title": "CSB Spectate Tools", | |
| 10 | + "short_desc": "Admin spectator helpers: a menu to jump into any player's first-person view, a HUD of their HP/armor/weapon, and amx_specme.", | |
| 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": "fakemeta,cstrike", | |
| 20 | + "install_notes": "1. Put csb_admin_spectate_tools.amxx in addons/amxmodx/plugins/\n2. Add it to addons/amxmodx/configs/plugins.ini\n3. Change map", | |
| 21 | + "known_conflicts": "Other plugins that force observer mode or rewrite pev_iuser1/iuser2 will fight this one for the spectator view.", | |
| 22 | + "cvars": [ | |
| 23 | + { | |
| 24 | + "name": "csb_spec_enabled", | |
| 25 | + "default": "1", | |
| 26 | + "description": "Enable or disable the spectate tools." | |
| 27 | + } | |
| 28 | + ], | |
| 29 | + "commands": [ | |
| 30 | + { | |
| 31 | + "name": "amx_spectate", | |
| 32 | + "access": "d (ADMIN_SLAY)", | |
| 33 | + "description": "Open a menu to watch a player in first person." | |
| 34 | + }, | |
| 35 | + { | |
| 36 | + "name": "amx_specme", | |
| 37 | + "access": "d (ADMIN_SLAY)", | |
| 38 | + "description": "Move yourself to spectator, remembering your team." | |
| 39 | + }, | |
| 40 | + { | |
| 41 | + "name": "amx_specback", | |
| 42 | + "access": "d (ADMIN_SLAY)", | |
| 43 | + "description": "Return to the team you had before amx_specme." | |
| 44 | + } | |
| 45 | + ], | |
| 46 | + "main": "addons/amxmodx/scripting/csb_admin_spectate_tools.sma" | |
| 47 | +} | |
| 0 | 48 |









