From bf364f9099a911e1ca31017c049a4f664974aaa7 Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Tue, 30 Apr 2024 00:20:04 +0300 Subject: [PATCH 1/2] add ConVar: `ca_mute_mode` --- .../addons/amxmodx/scripting/ChatAdditions/CA_Mute.sma | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cstrike/addons/amxmodx/scripting/ChatAdditions/CA_Mute.sma b/cstrike/addons/amxmodx/scripting/ChatAdditions/CA_Mute.sma index 6121b6b..4f7325b 100644 --- a/cstrike/addons/amxmodx/scripting/ChatAdditions/CA_Mute.sma +++ b/cstrike/addons/amxmodx/scripting/ChatAdditions/CA_Mute.sma @@ -17,7 +17,8 @@ new bool: g_globalMute[MAX_PLAYERS + 1] new Float: g_nextUse[MAX_PLAYERS + 1] new Float: ca_mute_use_delay, - bool: ca_mute_use_storage + bool: ca_mute_use_storage, + ca_mute_mode[4] new g_dummy, g_itemInfo[64], g_itemName[128] @@ -78,6 +79,12 @@ Create_CVars() { ), ca_mute_use_storage ) + + bind_pcvar_string(create_cvar("ca_mute_mode", "abcd", + .description = "Mute mode" + ), + ca_mute_mode, charsmax(ca_mute_mode) + ) } public ClCmd_Mute(const id) { From f3468ecb30d4a701cdd4ef0c76e5ae4aa664493e Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Tue, 30 Apr 2024 03:51:02 +0300 Subject: [PATCH 2/2] Implement SayText block and flags --- .../scripting/ChatAdditions/CA_Mute.sma | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/cstrike/addons/amxmodx/scripting/ChatAdditions/CA_Mute.sma b/cstrike/addons/amxmodx/scripting/ChatAdditions/CA_Mute.sma index 4f7325b..e5acaa1 100644 --- a/cstrike/addons/amxmodx/scripting/ChatAdditions/CA_Mute.sma +++ b/cstrike/addons/amxmodx/scripting/ChatAdditions/CA_Mute.sma @@ -16,6 +16,11 @@ new bool: g_globalMute[MAX_PLAYERS + 1] new Float: g_nextUse[MAX_PLAYERS + 1] +enum (<<=1) { + MuteFlag_Voice = (1 << 0), + MuteFlag_Chat, +} + new Float: ca_mute_use_delay, bool: ca_mute_use_storage, ca_mute_mode[4] @@ -55,6 +60,9 @@ public plugin_init() { Storage_Init() + // TODO: make it into API + register_message(get_user_msgid("SayText"), "UserMsg_SayText") + CA_Log(logLevel_Debug, "[CA]: Mute initialized!") } @@ -80,7 +88,7 @@ Create_CVars() { ca_mute_use_storage ) - bind_pcvar_string(create_cvar("ca_mute_mode", "abcd", + bind_pcvar_string(create_cvar("ca_mute_mode", "ab", .description = "Mute mode" ), ca_mute_mode, charsmax(ca_mute_mode) @@ -248,6 +256,10 @@ public client_disconnected(id) { } public CA_Client_Voice(const listener, const sender) { + new flags = read_flags(ca_mute_mode) + if (flags && !(read_flags(ca_mute_mode) & MuteFlag_Voice)) + return PLUGIN_CONTINUE + if (g_globalMute[listener]) { return CA_SUPERCEDE } @@ -263,6 +275,28 @@ public CA_Client_Voice(const listener, const sender) { return CA_CONTINUE } +public UserMsg_SayText(msgid, dest, receiver) { + if (get_msg_args() < 4) + return PLUGIN_CONTINUE + + new flags = read_flags(ca_mute_mode) + if (flags && !(read_flags(ca_mute_mode) & MuteFlag_Chat)) + return PLUGIN_CONTINUE + + new sender = get_msg_arg_int(1) + + if (g_globalMute[receiver]) + return PLUGIN_HANDLED + + if (g_globalMute[sender]) + return PLUGIN_HANDLED + + if (g_playersMute[receiver][sender] == true) + return PLUGIN_HANDLED + + return PLUGIN_CONTINUE +} + Storage_Init() { if (!SQL_SetAffinity("sqlite")) { set_fail_state("Can't user 'SQLite'. Check modules.ini")