Skip to content

Commit f9fc8f4

Browse files
Cosmetic fixes in the gag reasons menu (#202)
* separate conditions * gag: reasons: the bracket is open even if there is no time * gag: reasons menu: fixed when the closing bracket was applied regardless of the presence of the opening bracket Co-authored-by: Sergey Shorokhov <[email protected]>
1 parent c2a3346 commit f9fc8f4

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

cstrike/addons/amxmodx/scripting/CA_Gag.sma

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -397,15 +397,21 @@ static MenuShow_SelectReason(const id) {
397397
new buffer[2048]
398398
formatex(buffer, charsmax(buffer), reason[r_name])
399399

400-
if(reason[r_time] > 0) {
401-
strcat(buffer, fmt(" (\\y%s", Get_TimeString_seconds(id, reason[r_time])), charsmax(buffer))
402-
}
400+
new bool: reasonHasTime = (reason[r_time] != 0)
401+
new bool: reasonHasFlags = (reason[r_flags] != gagFlag_Removed)
403402

404-
if(reason[r_flags] != gagFlag_Removed) {
405-
strcat(buffer, fmt(", %s", bits_to_flags(reason[r_flags])), charsmax(buffer))
403+
if(reasonHasTime || reasonHasFlags) {
404+
strcat(buffer, " (\\y$time$flags\\w)", charsmax(buffer))
406405
}
407406

408-
strcat(buffer, "\\w)", charsmax(buffer))
407+
replace_stringex(buffer, charsmax(buffer), "$time",
408+
reasonHasTime ? Get_TimeString_seconds(id, reason[r_time]) : ""
409+
)
410+
411+
replace_stringex(buffer, charsmax(buffer), "$flags",
412+
reasonHasFlags ? fmt("%s%s", (reasonHasTime && reasonHasFlags) ? ", " : "", bits_to_flags(reason[r_flags])) : ""
413+
)
414+
409415
menu_additem(menu, buffer, fmt("%i", i))
410416
}
411417
} else {

0 commit comments

Comments
 (0)