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 1 commit
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
Prev Previous commit
Implement SayText block and flags
SergeyShorokhov committed Apr 30, 2024
commit f3468ecb30d4a701cdd4ef0c76e5ae4aa664493e
36 changes: 35 additions & 1 deletion cstrike/addons/amxmodx/scripting/ChatAdditions/CA_Mute.sma
Original file line number Diff line number Diff line change
@@ -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")