Skip to content
View in the app

A better way to browse. Learn more.

Learn more

block-fire-in-the-hole-radio/addons/amxmodx/scripting/olds_nofireinhole.sma

olds_nofireinhole.sma
127 lines · 4.3 KB · Pawn (AMX Mod X)
Raw
/*
 * Block Fire-in-the-Hole Radio (olds.ro workshop card LIB-0105)
 *
 * When a player (or a bot) throws a HE grenade, a flashbang or a smoke
 * grenade, the game makes him shout "Fire in the hole!" on the team radio:
 * a voice line and a chat line for every teammate. This plugin drops both.
 * Every other radio message (Go go go, Roger that, ...) still plays.
 *
 * Commands: none.
 *
 * Cvars (in configs/plugins/olds_nofireinhole.cfg, which ships with the
 * plugin; if the file is missing, the plugin writes it with these defaults
 * the first time it starts):
 *   olds_nf_enable       1  1 = drop the Fire in the hole radio; 0 = the
 *                           game's normal radio.
 *   olds_nf_admins_hear  0  1 = admins (any access flag besides the
 *                           default "z") still hear and see it.
 *
 * How it works, as the card asks: register_message hooks on TextMsg and
 * SendAudio. A TextMsg radio line (#Game_radio, or #Game_radio_location
 * when the game adds the place name) that ends with #Fire_in_the_hole, and
 * a SendAudio with %!MRAD_FIREINHOLE, are blocked with PLUGIN_HANDLED. The
 * game sends both messages to each teammate separately, so for an admin
 * they can be let through while everyone else is spared. The plugin shows
 * no text, so it has no language file.
 *
 * Requires AMX Mod X 1.10. Written for AMX Mod X 1.10.0.5490 with
 * ReGameDLL_CS 5.30.0.814 (works with the stock game too).
 *
 * 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 <amxmisc>

#pragma semicolon 1

new const PLUGIN_NAME[] = "Block Fire-in-the-Hole Radio";
new const PLUGIN_VERSION[] = "1.0.0";
new const PLUGIN_AUTHOR[] = "alexit (olds.ro)";

// What the game sends for the grenade radio.
new const RADIO_TEXT[] = "#Fire_in_the_hole";
new const RADIO_AUDIO[] = "%!MRAD_FIREINHOLE";

// TextMsg destination of radio lines (HUD_PRINTRADIO in the game).
const PRINT_RADIO = 5;

new g_enabled;         // olds_nf_enable
new g_adminsHear;      // olds_nf_admins_hear

public plugin_init()
{
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);

	bind_pcvar_num(create_cvar("olds_nf_enable", "1", FCVAR_NONE,
		"1 = drop the Fire in the hole radio (voice and text); 0 = the game's normal radio",
		true, 0.0, true, 1.0), g_enabled);

	bind_pcvar_num(create_cvar("olds_nf_admins_hear", "0", FCVAR_NONE,
		"1 = admins (any access flag besides the default z) still hear and see Fire in the hole",
		true, 0.0, true, 1.0), g_adminsHear);

	AutoExecConfig(true, "olds_nofireinhole");

	register_message(get_user_msgid("TextMsg"), "msg_text");
	register_message(get_user_msgid("SendAudio"), "msg_audio");
}

/**
 * The radio chat line: TextMsg(5, sender, "#Game_radio", name, text) or
 * TextMsg(5, sender, "#Game_radio_location", name, place, text).
 */
public msg_text(msgId, msgDest, receiver)
{
	if (!g_enabled || get_msg_args() < 5 || get_msg_arg_int(1) != PRINT_RADIO)
		return PLUGIN_CONTINUE;

	new kind[32], text[32];
	get_msg_arg_string(3, kind, charsmax(kind));

	if (!equal(kind, "#Game_radio") && !equal(kind, "#Game_radio_location"))
		return PLUGIN_CONTINUE;

	get_msg_arg_string(get_msg_args(), text, charsmax(text));

	if (!equal(text, RADIO_TEXT) || lets_through(receiver))
		return PLUGIN_CONTINUE;

	return PLUGIN_HANDLED;
}

/**
 * The radio voice: SendAudio(sender, "%!MRAD_FIREINHOLE", pitch).
 */
public msg_audio(msgId, msgDest, receiver)
{
	if (!g_enabled || get_msg_args() < 2)
		return PLUGIN_CONTINUE;

	new sample[32];
	get_msg_arg_string(2, sample, charsmax(sample));

	if (!equal(sample, RADIO_AUDIO) || lets_through(receiver))
		return PLUGIN_CONTINUE;

	return PLUGIN_HANDLED;
}

/**
 * With olds_nf_admins_hear 1 an admin still gets the message.
 */
bool:lets_through(receiver)
{
	return g_adminsHear && receiver >= 1 && receiver <= MaxClients && is_user_admin(receiver);
}

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.