diff --git a/cstrike/addons/amxmodx/scripting/ChatAdditions/CA_Mute.sma b/cstrike/addons/amxmodx/scripting/ChatAdditions/CA_Mute.sma index 6121b6b..e5acaa1 100644 --- a/cstrike/addons/amxmodx/scripting/ChatAdditions/CA_Mute.sma +++ b/cstrike/addons/amxmodx/scripting/ChatAdditions/CA_Mute.sma @@ -16,8 +16,14 @@ 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 + bool: ca_mute_use_storage, + ca_mute_mode[4] new g_dummy, g_itemInfo[64], g_itemName[128] @@ -54,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!") } @@ -78,6 +87,12 @@ Create_CVars() { ), ca_mute_use_storage ) + + bind_pcvar_string(create_cvar("ca_mute_mode", "ab", + .description = "Mute mode" + ), + ca_mute_mode, charsmax(ca_mute_mode) + ) } public ClCmd_Mute(const id) { @@ -241,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 } @@ -256,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")