Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: mute flags mode #333

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion cstrike/addons/amxmodx/scripting/ChatAdditions/CA_Mute.sma
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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!")
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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
}
Expand All @@ -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")
Expand Down