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

new CVar: ca_gag_common_chat_block #242

Merged
merged 4 commits into from
Dec 19, 2021
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,11 @@ ca_gag_block_nickname_change "1"
// -
// Default: "1"
ca_gag_block_admin_chat "1"

// Don't separate `say` & `say_team` chats
// 0 = disabled
// -
// Default: "1"
ca_gag_common_chat_block "1"


45 changes: 32 additions & 13 deletions cstrike/addons/amxmodx/scripting/CA_Gag.sma
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ new ca_gag_times[64],
ca_gag_sound_ok[128],
ca_gag_sound_error[128],
bool: ca_gag_block_nickname_change,
bool: ca_gag_block_admin_chat
bool: ca_gag_block_admin_chat,
bool: ca_gag_common_chat_block

new g_dummy, g_itemInfo[64], g_itemName[128]

Expand Down Expand Up @@ -207,6 +208,13 @@ Register_CVars() {
),
ca_gag_block_admin_chat
)

bind_pcvar_num(create_cvar("ca_gag_common_chat_block", "1",
.description = "Don't separate `say` & `say_team` chats\n \
0 = disabled"
),
ca_gag_common_chat_block
)
}

public client_putinserver(id) {
Expand Down Expand Up @@ -638,10 +646,12 @@ static MenuShow_SelectFlags(const id) {
(gagFlags & gagFlag_Say) ? " \\r+\\w " : "-"),
fmt("%i", gagFlag_Say)
)
menu_additem(menu, fmt("%L [ %s ]", id, "Gag_MenuItem_PropSayTeam",
(gagFlags & gagFlag_SayTeam) ? " \\r+\\w " : "-"),
fmt("%i", gagFlag_SayTeam)
)
if(!ca_gag_common_chat_block) {
menu_additem(menu, fmt("%L [ %s ]", id, "Gag_MenuItem_PropSayTeam",
(gagFlags & gagFlag_SayTeam) ? " \\r+\\w " : "-"),
fmt("%i", gagFlag_SayTeam)
)
}
menu_additem(menu, fmt("%L [ %s ]", id, "Gag_MenuItem_PropVoice",
(gagFlags & gagFlag_Voice) ? " \\r+\\w " : "-"),
fmt("%i", gagFlag_Voice)
Expand Down Expand Up @@ -718,7 +728,9 @@ public MenuHandler_SelectFlags(const id, const menu, const item) {
new itemIndex = strtol(g_itemInfo)

switch(itemIndex) {
case gagFlag_Say: g_adminTempData[id][gd_reason][r_flags] ^= gagFlag_Say
case gagFlag_Say: {
g_adminTempData[id][gd_reason][r_flags] ^= (!ca_gag_common_chat_block ? gagFlag_Say : (gagFlag_Say | gagFlag_SayTeam))
}
case gagFlag_SayTeam: g_adminTempData[id][gd_reason][r_flags] ^= gagFlag_SayTeam
case gagFlag_Voice: g_adminTempData[id][gd_reason][r_flags] ^= gagFlag_Voice

Expand Down Expand Up @@ -910,11 +922,15 @@ static MenuShow_EditGag(const id) {
),
fmt("%i", gagFlag_Say)
)
menu_additem(menu, fmt("%L [ %s ]", id, "Gag_MenuItem_PropSayTeam",
(gagFlags & gagFlag_SayTeam) ? " \\r+\\w " : "-"
),
fmt("%i", gagFlag_SayTeam)
)

if(!ca_gag_common_chat_block) {
menu_additem(menu, fmt("%L [ %s ]", id, "Gag_MenuItem_PropSayTeam",
(gagFlags & gagFlag_SayTeam) ? " \\r+\\w " : "-"
),
fmt("%i", gagFlag_SayTeam)
)
}

menu_additem(menu, fmt("%L [ %s ]", id, "Gag_MenuItem_PropVoice",
(gagFlags & gagFlag_Voice) ? " \\r+\\w " : "-"
),
Expand Down Expand Up @@ -1299,7 +1315,7 @@ public CA_Client_SayTeam(id, const message[]) {
if(CmdRouter(id, message))
return PLUGIN_CONTINUE

new bool: hasBlock = (g_currentGags[id][gd_reason][r_flags] & gagFlag_SayTeam)
new bool: hasBlock = bool: (g_currentGags[id][gd_reason][r_flags] & (ca_gag_common_chat_block ? gagFlag_SayTeam : gagFlag_Say))

if(!hasBlock) {
return CA_CONTINUE
Expand Down Expand Up @@ -1542,14 +1558,17 @@ static bool: IsTargetHasImmunity(const id, const target) {
return false
}

static Get_GagFlags_Names(const gag_flags_s: flags) {
static Get_GagFlags_Names(gag_flags_s: flags) {
// TODO: ML this

new buffer[64]
new const GAG_FLAGS_STR[][] = {
"Chat", "Team chat", "Voice"
}

if(ca_gag_common_chat_block && (flags & gagFlag_SayTeam))
flags ^= gagFlag_SayTeam

for(new i = 0; i < sizeof(GAG_FLAGS_STR); i++) {
if(flags & gag_flags_s: (1 << i)) {
strcat(buffer, fmt("%s + ", GAG_FLAGS_STR[i]), charsmax(buffer));
Expand Down