Skip to content

Commit f0389a3

Browse files
committed
fix(gag): 🐛 fix EditGag menu reason edit
1 parent 35a8646 commit f0389a3

File tree

1 file changed

+29
-31
lines changed

1 file changed

+29
-31
lines changed

cstrike/addons/amxmodx/scripting/CA_Gag.sma

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ new g_dummy, g_itemInfo[64], g_itemName[128]
4040
enum {
4141
ITEM_ENTER_GAG_REASON = -1,
4242
ITEM_ENTER_GAG_TIME = -2,
43-
ITEM_CONFIRM = -3
43+
ITEM_CONFIRM = -3,
44+
ITEM_REASON = -4,
4445
}
4546

4647
new g_fwd_gag_setted,
@@ -942,7 +943,7 @@ static MenuShow_EditGag(const id) {
942943
menu_additem(menu, fmt("%L [ \\r%s\\w ]", id, "Gag_MenuItem_Reason",
943944
Get_GagString_reason(id, target)
944945
),
945-
fmt("%i", 1)
946+
fmt("%i", ITEM_REASON)
946947
)
947948
menu_addtext(menu, fmt(" %L [ \\r%s\\w ]", id, "Gag_MenuItem_Time",
948949
Get_TimeString_seconds(id, g_adminTempData[id][gd_reason][r_time])
@@ -996,8 +997,6 @@ public MenuCallback_EditGag(const id, const menu, const item) {
996997
}
997998

998999
public MenuHandler_EditGag(const id, const menu, const item) {
999-
enum { item_Say, item_SayTeam, item_Voice, item_Reason }
1000-
10011000
if(item == MENU_EXIT || item < 0) {
10021001
MenuShow_PlayersList(id)
10031002

@@ -1015,45 +1014,44 @@ public MenuHandler_EditGag(const id, const menu, const item) {
10151014
return PLUGIN_HANDLED
10161015
}
10171016

1018-
switch(item) {
1019-
case item_Say: g_adminTempData[id][gd_reason][r_flags] ^= gagFlag_Say
1020-
case item_SayTeam: g_adminTempData[id][gd_reason][r_flags] ^= (ca_gag_common_chat_block ? gagFlag_Voice : gagFlag_SayTeam)
1021-
case item_Voice: g_adminTempData[id][gd_reason][r_flags] ^= gagFlag_Voice // not used when `ca_gag_common_chat_block` is 1
1022-
case item_Reason: {
1017+
1018+
menu_item_getinfo(menu, item, g_dummy, g_itemInfo, charsmax(g_itemInfo), g_itemName, charsmax(g_itemName), g_dummy)
1019+
new itemIndex = strtol(g_itemInfo)
1020+
1021+
switch(itemIndex) {
1022+
case gagFlag_Say: g_adminTempData[id][gd_reason][r_flags] ^= gagFlag_Say
1023+
case gagFlag_SayTeam: g_adminTempData[id][gd_reason][r_flags] ^= gagFlag_SayTeam
1024+
case gagFlag_Voice: g_adminTempData[id][gd_reason][r_flags] ^= gagFlag_Voice
1025+
case ITEM_REASON: {
10231026
MenuShow_SelectReason(id)
10241027

10251028
menu_destroy(menu)
10261029
return PLUGIN_HANDLED
10271030
}
1028-
}
1029-
1030-
menu_item_getinfo(menu, item, g_dummy, g_itemInfo, charsmax(g_itemInfo), g_itemName, charsmax(g_itemName), g_dummy)
1031-
1032-
new itemIndex = strtol(g_itemInfo)
1033-
1034-
if(itemIndex == ITEM_CONFIRM) {
1035-
new time = g_adminTempData[id][gd_reason][r_time]
1036-
new flags = g_adminTempData[id][gd_reason][r_flags]
1031+
case ITEM_CONFIRM: {
1032+
new time = g_adminTempData[id][gd_reason][r_time]
1033+
new flags = g_adminTempData[id][gd_reason][r_flags]
10371034

1038-
new bool: timeChanged = (g_currentGags[target][gd_reason][r_time] != time)
1035+
new bool: timeChanged = (g_currentGags[target][gd_reason][r_time] != time)
10391036

1040-
new expireAt = timeChanged ? 0 : g_adminTempData[id][gd_expireAt]
1037+
new expireAt = timeChanged ? 0 : g_adminTempData[id][gd_expireAt]
10411038

1042-
new gagTimeStr[32]; copy(gagTimeStr, charsmax(gagTimeStr), Get_TimeString_seconds(LANG_PLAYER, time))
1039+
new gagTimeStr[32]; copy(gagTimeStr, charsmax(gagTimeStr), Get_TimeString_seconds(LANG_PLAYER, time))
10431040

1044-
CA_Log(logLevel_Info, "Gag: \"%s\" edit gag for \"%s\" (type:\"%s\") (time:\"%s\") (reason:\"%s\")", \
1045-
g_adminTempData[id][gd_adminName], g_adminTempData[id][gd_name], \
1046-
bits_to_flags(gag_flags_s: g_adminTempData[id][gd_reason][r_flags]), \
1047-
gagTimeStr, g_adminTempData[id][gd_reason][r_name] \
1048-
)
1041+
CA_Log(logLevel_Info, "Gag: \"%s\" edit gag for \"%s\" (type:\"%s\") (time:\"%s\") (reason:\"%s\")", \
1042+
g_adminTempData[id][gd_adminName], g_adminTempData[id][gd_name], \
1043+
bits_to_flags(gag_flags_s: g_adminTempData[id][gd_reason][r_flags]), \
1044+
gagTimeStr, g_adminTempData[id][gd_reason][r_name] \
1045+
)
10491046

1050-
Gag_Save(id, target, time, flags, expireAt)
1047+
Gag_Save(id, target, time, flags, expireAt)
10511048

1052-
GagData_Reset(g_adminTempData[id])
1053-
g_inEditMenu[id] = false
1049+
GagData_Reset(g_adminTempData[id])
1050+
g_inEditMenu[id] = false
10541051

1055-
menu_destroy(menu)
1056-
return PLUGIN_HANDLED
1052+
menu_destroy(menu)
1053+
return PLUGIN_HANDLED
1054+
}
10571055
}
10581056

10591057
MenuShow_EditGag(id)

0 commit comments

Comments
 (0)