/*
* Death Message Disabler (olds.ro workshop card LIB-1552)
*
* Turns the kill feed (the "A killed B" lines at the top right of the
* screen) off for everyone, for modes where kills should be silent. Frags,
* deaths, the scoreboard and stats plugins keep working as usual.
*
* Admin command (ADMIN_CFG, flag "h"; also from the server console):
* amx_deathmsg <0|1> sets olds_nodeath at once: 1 = kill feed hidden,
* 0 = kill feed shown again. Without a value it
* prints which one is in use.
*
* Server command:
* olds_nodeath_status prints the settings, how many kill feed lines were
* hidden, shown and sent to admins, and the last kill
*
* Cvars (saved with their descriptions in configs/plugins/olds_nodeath.cfg
* the first time the plugin starts):
* olds_nodeath 1 1 = no kill feed lines for anyone, 0 = as usual
* olds_nodeath_admin 0 1 = admins (any admin flag) still see the kill
* feed while it is hidden for the other players
*
* How it works: the game's DeathMsg is caught with register_message and
* blocked (PLUGIN_HANDLED). Only that message is touched: the game updates
* the scoreboard with its own ScoreInfo messages, which are not blocked,
* and other plugins still see every kill through the DeathMsg event. With
* olds_nodeath_admin 1 the same line is sent to each admin on their own.
*
* Requires AMX Mod X 1.10 or newer. No extra modules and no ReAPI.
*
* 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[] = "Death Message Disabler";
new const PLUGIN_VERSION[] = "1.0.0";
new const PLUGIN_AUTHOR[] = "alexit (olds.ro)";
new const DICTIONARY[] = "olds_nodeath.txt";
new const STATE_KEYS[][] = { "OLDS_ND_STATE_OFF", "OLDS_ND_STATE_ON" };
new const CHAT_KEYS[][] = { "OLDS_ND_CHAT_OFF", "OLDS_ND_CHAT_ON" };
new g_pcvarEnabled;
new g_enabled; // olds_nodeath
new g_adminsSee; // olds_nodeath_admin
new g_msgDeathMsg;
// For olds_nodeath_status.
new g_hidden;
new g_shown;
new g_sentToAdmins;
new g_lastKill[128];
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
register_dictionary(DICTIONARY);
g_pcvarEnabled = create_cvar("olds_nodeath", "1", FCVAR_NONE,
"1 = no kill feed lines for anyone, 0 = the kill feed as usual",
true, 0.0, true, 1.0);
bind_pcvar_num(g_pcvarEnabled, g_enabled);
bind_pcvar_num(create_cvar("olds_nodeath_admin", "0", FCVAR_NONE,
"1 = admins still see the kill feed while it is hidden for the other players",
true, 0.0, true, 1.0), g_adminsSee);
AutoExecConfig(true, "olds_nodeath");
register_concmd("amx_deathmsg", "cmd_deathmsg", ADMIN_CFG, "OLDS_ND_HELP", -1, true);
register_srvcmd("olds_nodeath_status", "cmd_status");
g_msgDeathMsg = get_user_msgid("DeathMsg");
register_message(g_msgDeathMsg, "msg_death");
}
/**
* The game's kill feed line: killer, victim, headshot, weapon (and, on newer
* game versions, more values for newer clients).
*/
public msg_death(msgId, msgDest, msgEntity)
{
new killer = get_msg_arg_int(1);
new victim = get_msg_arg_int(2);
new weapon[32];
get_msg_arg_string(4, weapon, charsmax(weapon));
new killerName[MAX_NAME_LENGTH], victimName[MAX_NAME_LENGTH];
player_name(killer, killerName, charsmax(killerName));
player_name(victim, victimName, charsmax(victimName));
formatex(g_lastKill, charsmax(g_lastKill), "%s -> %s with %s", killerName, victimName, weapon);
if (!g_enabled)
{
g_shown++;
add(g_lastKill, charsmax(g_lastKill), " (shown)");
return PLUGIN_CONTINUE;
}
g_hidden++;
new admins;
if (g_adminsSee)
{
for (new id = 1; id <= MaxClients; id++)
{
if (is_user_connected(id) && is_user_admin(id))
{
send_copy(id);
admins++;
}
}
g_sentToAdmins += admins;
}
new note[48];
formatex(note, charsmax(note), " (hidden, sent to %d admin(s))", admins);
add(g_lastKill, charsmax(g_lastKill), note);
return PLUGIN_HANDLED;
}
/**
* Sends the DeathMsg being handled to one player, value by value, so any
* extra values the game adds are kept.
*/
send_copy(id)
{
new text[64];
new count = get_msg_args();
message_begin(MSG_ONE, g_msgDeathMsg, _, id);
for (new i = 1; i <= count; i++)
{
switch (get_msg_argtype(i))
{
case ARG_BYTE: write_byte(get_msg_arg_int(i));
case ARG_CHAR: write_char(get_msg_arg_int(i));
case ARG_SHORT: write_short(get_msg_arg_int(i));
case ARG_LONG: write_long(get_msg_arg_int(i));
case ARG_ANGLE: write_angle_f(get_msg_arg_float(i));
case ARG_COORD: write_coord_f(get_msg_arg_float(i));
case ARG_ENTITY: write_entity(get_msg_arg_int(i));
case ARG_STRING:
{
get_msg_arg_string(i, text, charsmax(text));
write_string(text);
}
}
}
message_end();
}
player_name(id, out[], maxLength)
{
if (1 <= id <= MaxClients && is_user_connected(id))
get_user_name(id, out, maxLength);
else
copy(out, maxLength, "world");
}
/**
* amx_deathmsg <0|1>
*/
public cmd_deathmsg(id, level, cid)
{
if (!admin_allowed(id, level))
return PLUGIN_HANDLED;
if (read_argc() < 2)
{
console_print(id, "%L", id, STATE_KEYS[g_enabled ? 1 : 0]);
return PLUGIN_HANDLED;
}
new arg[8];
read_argv(1, arg, charsmax(arg));
if (!equal(arg, "0") && !equal(arg, "1"))
{
console_print(id, "%L", id, "OLDS_ND_USAGE");
return PLUGIN_HANDLED;
}
new value = str_to_num(arg);
set_pcvar_num(g_pcvarEnabled, value);
console_print(id, "%L", id, STATE_KEYS[value]);
new name[MAX_NAME_LENGTH];
if (id)
get_user_name(id, name, charsmax(name));
else
copy(name, charsmax(name), "Server");
client_print_color(0, print_team_default, "^1%L", LANG_PLAYER, CHAT_KEYS[value], name);
new who[96];
describe_admin(id, who, charsmax(who));
if (value)
log_amx("Cmd: %s set olds_nodeath 1 (kill feed hidden)", who);
else
log_amx("Cmd: %s set olds_nodeath 0 (kill feed shown)", who);
return PLUGIN_HANDLED;
}
/**
* olds_nodeath_status
*/
public cmd_status()
{
server_print("[olds_nodeath] olds_nodeath %d, olds_nodeath_admin %d", g_enabled, g_adminsSee);
server_print("[olds_nodeath] kill feed lines: %d hidden, %d shown, %d sent to admins",
g_hidden, g_shown, g_sentToAdmins);
if (g_lastKill[0])
server_print("[olds_nodeath] last kill: %s", g_lastKill);
else
server_print("[olds_nodeath] last kill: none yet");
return PLUGIN_HANDLED;
}
/**
* The same rules as cmd_access: the server console (and the host of a listen
* server) may always; ADMIN_ALL = everyone; ADMIN_ADMIN = any admin flag.
* The level can be changed in configs/cmdaccess.ini.
*/
bool:admin_allowed(id, level)
{
if (id == (is_dedicated_server() ? 0 : 1) || level == ADMIN_ALL)
return true;
if ((level == ADMIN_ADMIN && is_user_admin(id)) || (get_user_flags(id) & level))
return true;
console_print(id, "%L", id, "OLDS_ND_NO_ACCESS");
return false;
}
describe_admin(id, out[], maxLength)
{
if (!id)
{
copy(out, maxLength, "Server");
return;
}
new name[MAX_NAME_LENGTH], authid[44];
get_user_name(id, name, charsmax(name));
get_user_authid(id, authid, charsmax(authid));
formatex(out, maxLength, "^"%s<%d><%s><>^"", name, get_user_userid(id), authid);
}