/*
* Bomb Mute (olds.ro workshop card LIB-0114)
*
* The planted bomb stops beeping, and optionally its red light stops
* blinking, for a quieter round. It can be done for Counter-Terrorists
* only, so Terrorists still hear and see their bomb.
*
* Commands: none.
*
* Cvars (in configs/plugins/olds_bombmute.cfg, which ships with the plugin;
* if the file is missing, the plugin writes it with these defaults the first
* time it starts):
* olds_bq_beep 1 1 = the bomb's beep is not heard.
* olds_bq_blink 0 1 = the bomb's red light does not blink.
* olds_bq_ct_only 0 1 = only Counter-Terrorists lose the beep and the
* light; Terrorists and spectators keep them.
*
* Rules:
* - Only the countdown beep (weapons/c4_beep1-5.wav) and the blinking
* light are touched. The plant, defuse and explosion sounds and the
* explosion itself stay as they are.
* - Nothing changes on the players' computers: the server simply does not
* send the beep or the light.
*
* How it works, as the card asks: the engine sound forward FM_EmitSound
* blocks the CHAN_VOICE weapons/c4_beep*.wav samples. The blinking light is
* a TE_GLOWSPRITE temporary entity the bomb sends every 2 seconds (the C4
* model has no blinking skin to change), so it is blocked in the
* SVC_TEMPENTITY message. With olds_bq_ct_only 1 the blocked beep is sent
* again to every non-CT player alone (ReAPI rh_emit_sound2), and the light
* the same way.
*
* Requires AMX Mod X 1.10 with ReAPI (ReHLDS and ReGameDLL_CS) and the
* fakemeta module. Written for AMX Mod X 1.10.0.5490, ReAPI 5.29.0.358,
* ReGameDLL_CS 5.30.0.814 and ReHLDS 3.15.0.896.
*
* Copyright (C) 2026 alexit (olds.ro workshop)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* 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.
*
* This program 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 the GNU General Public License for
* more details: <https://www.gnu.org/licenses/>.
*/
#include <amxmodx>
#include <fakemeta>
#include <reapi>
#pragma semicolon 1
new const PLUGIN_NAME[] = "Bomb Mute";
new const PLUGIN_VERSION[] = "1.0.0";
new const PLUGIN_AUTHOR[] = "alexit (olds.ro)";
new const BEEP_PREFIX[] = "weapons/c4_beep";
new const GLOW_SPRITE[] = "sprites/ledglow.spr";
new g_muteBeep; // olds_bq_beep
new g_hideBlink; // olds_bq_blink
new g_ctOnly; // olds_bq_ct_only
new g_glowSprite;
public plugin_precache()
{
// The game precaches it already; this only gives its index.
g_glowSprite = precache_model(GLOW_SPRITE);
}
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
if (!is_regamedll() || !is_rehlds())
set_fail_state("ReHLDS or ReGameDLL_CS is not running. This plugin needs ReHLDS, ReGameDLL_CS and ReAPI.");
bind_pcvar_num(create_cvar("olds_bq_beep", "1", FCVAR_NONE,
"1 = the bomb's beep is not heard",
true, 0.0, true, 1.0), g_muteBeep);
bind_pcvar_num(create_cvar("olds_bq_blink", "0", FCVAR_NONE,
"1 = the bomb's red light does not blink",
true, 0.0, true, 1.0), g_hideBlink);
bind_pcvar_num(create_cvar("olds_bq_ct_only", "0", FCVAR_NONE,
"1 = only Counter-Terrorists lose the beep and the light; Terrorists keep them",
true, 0.0, true, 1.0), g_ctOnly);
AutoExecConfig(true, "olds_bombmute");
register_forward(FM_EmitSound, "on_emit_sound");
register_message(SVC_TEMPENTITY, "on_temp_entity");
}
/**
* A sound from an entity: the bomb's beep is dropped.
*/
public on_emit_sound(entity, channel, const sample[], Float:volume, Float:attenuation, flags, pitch)
{
if (!g_muteBeep || channel != CHAN_VOICE || !equal(sample, BEEP_PREFIX, charsmax(BEEP_PREFIX)))
return FMRES_IGNORED;
if (g_ctOnly)
{
// The others still hear it: one copy each.
for (new id = 1; id <= MaxClients; id++)
{
if (keeps_bomb_signals(id))
rh_emit_sound2(entity, id, channel, sample, volume, attenuation, flags, pitch);
}
}
return FMRES_SUPERCEDE;
}
/**
* TE_GLOWSPRITE: x, y, z, sprite, scale, life, brightness. The bomb's light
* uses sprites/ledglow.spr.
*/
public on_temp_entity(msgId, msgDest, msgEntity)
{
if (!g_hideBlink || get_msg_arg_int(1) != TE_GLOWSPRITE || get_msg_arg_int(5) != g_glowSprite)
return PLUGIN_CONTINUE;
if (g_ctOnly)
{
new Float:origin[3];
origin[0] = get_msg_arg_float(2);
origin[1] = get_msg_arg_float(3);
origin[2] = get_msg_arg_float(4);
new scale = get_msg_arg_int(6);
new life = get_msg_arg_int(7);
new brightness = get_msg_arg_int(8);
for (new id = 1; id <= MaxClients; id++)
{
if (!keeps_bomb_signals(id))
continue;
message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id);
write_byte(TE_GLOWSPRITE);
write_coord_f(origin[0]);
write_coord_f(origin[1]);
write_coord_f(origin[2]);
write_short(g_glowSprite);
write_byte(scale);
write_byte(life);
write_byte(brightness);
message_end();
}
}
return PLUGIN_HANDLED;
}
/**
* With olds_bq_ct_only 1: everyone but the Counter-Terrorists (bots need no
* copy).
*/
bool:keeps_bomb_signals(id)
{
return is_user_connected(id) && !is_user_bot(id) && TeamName:get_member(id, m_iTeam) != TEAM_CT;
}