/* * CSB Admin Godmode * Copyright (C) 2026 counter-strike-boost.com * * Toggles invulnerability on a target with set_user_godmode, shows a small HUD * marker while it is active, and clears it automatically on death, disconnect * and map change. Restricted to a high access flag and announced to admins. * * Inspired by the god-mode command from the classic AMX Mod X Admin Commands * plugin (AMX Mod X Development Team). 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 for details. */ #include #include #include new const PLUGIN[] = "CSB Admin Godmode" new const VERSION[] = "1.0.0" new const AUTHOR[] = "counter-strike-boost.com" new bool:g_bGod[33] new g_pEnabled, g_pHud new g_iSyncHud public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) g_pEnabled = register_cvar("csb_god_enabled", "1") g_pHud = register_cvar("csb_god_hud", "1") register_concmd("amx_god", "cmdGod", ADMIN_CFG, " [0|1] - toggle godmode on a target") register_event("DeathMsg", "eventDeath", "a", "1>0") g_iSyncHud = CreateHudSyncObj() set_task(1.0, "taskHud", 0, _, _, "b") } public client_disconnected(id) { g_bGod[id] = false } public eventDeath() { new victim = read_data(2) if (victim >= 1 && victim <= 32 && g_bGod[victim]) { g_bGod[victim] = false if (is_user_connected(victim)) { set_user_godmode(victim, 0) client_print(victim, print_chat, "[CSB] Your godmode was cleared on death.") } } } public cmdGod(id, level, cid) { if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED if (!get_pcvar_num(g_pEnabled)) { console_print(id, "[CSB] Godmode is disabled (csb_god_enabled 0).") return PLUGIN_HANDLED } new arg[32] read_argv(1, arg, charsmax(arg)) new target = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF) if (!target) return PLUGIN_HANDLED if (!is_user_alive(target)) { client_print(id, print_chat, "[CSB] That player is not alive.") return PLUGIN_HANDLED } new bool:want if (read_argc() > 2) { new stateArg[4] read_argv(2, stateArg, charsmax(stateArg)) want = (str_to_num(stateArg) != 0) } else { want = !g_bGod[target] } g_bGod[target] = want set_user_godmode(target, want ? 1 : 0) new aname[32], tname[32] getAdminName(id, aname, charsmax(aname)) get_user_name(target, tname, charsmax(tname)) new msg[160] formatex(msg, charsmax(msg), "^x04[CSB]^x03 %s^x01 turned godmode^x04 %s^x01 for^x03 %s^x01.", aname, want ? "ON" : "OFF", tname) adminChat(msg) log_amx("[CSB Godmode] %s set godmode %s for %s", aname, want ? "on" : "off", tname) return PLUGIN_HANDLED } public taskHud() { if (!get_pcvar_num(g_pHud)) return new players[32], num, pid get_players(players, num, "a") for (new i = 0; i < num; i++) { pid = players[i] if (!g_bGod[pid]) continue set_hudmessage(0, 255, 128, -1.0, 0.75, 0, 0.0, 1.1, 0.0, 0.0, -1) ShowSyncHudMsg(pid, g_iSyncHud, "[ GODMODE ]") } } getAdminName(id, name[], len) { if (id) get_user_name(id, name, len) else copy(name, len, "CONSOLE") } adminChat(const msg[]) { new players[32], num, pid, msgid = get_user_msgid("SayText") get_players(players, num, "ch") for (new i = 0; i < num; i++) { pid = players[i] if (!(get_user_flags(pid) & ADMIN_CFG)) continue message_begin(MSG_ONE, msgid, _, pid) write_byte(pid) write_string(msg) message_end() } }