@@ -26,6 +26,8 @@ enum NotifyType_s: {
2626
2727new bool: g_canSpeakWithAlive[MAX_PLAYERS + 1 ] = { false , ... }
2828
29+ new g_syncHudOj
30+
2931public stock const PluginName[] = " CA Addon: Death mute"
3032public stock const PluginVersion[] = CA_VERSION
3133public stock const PluginAuthor[] = " Sergey Shorokhov"
@@ -42,6 +44,8 @@ public plugin_init() {
4244
4345 RegisterHookChain (RG_CBasePlayer_Killed, " CBasePlayer_Killed" , .post = true )
4446 RegisterHookChain (RG_CSGameRules_PlayerSpawn, " CBasePlayer_Spawn" , .post = true )
47+
48+ g_syncHudOj = CreateHudSyncObj ()
4549}
4650
4751Register_CVars () {
@@ -145,25 +149,29 @@ public CBasePlayer_Killed(const id, const attacker) {
145149
146150 set_task_ex (ca_deathmute_time, " DisableSpeakWithAlive" , .id = id)
147151
148- if (ca_deathmute_notify_type == notify_Disabled) {
149- return
150- }
152+ switch (ca_deathmute_notify_type) {
153+ case notify_Disabled: return
151154
152- if (ca_deathmute_notify_type == notify_Chat) {
153- client_print_color (id, print_team_red, " % L % L" , id, " DeathMute_prefix" , id, " DeathMute_ChatMessage" , ca_deathmute_time)
154- }
155+ case notify_Chat: client_print_color (id, print_team_red, " % L % L" , id, " DeathMute_prefix" , id, " DeathMute_ChatMessage" , ca_deathmute_time)
156+
157+ case notify_HUD: {
158+ set_hudmessage (
159+ ca_deathmute_notify_hud_r,
160+ ca_deathmute_notify_hud_g,
161+ ca_deathmute_notify_hud_b,
162+ ca_deathmute_notify_hud_x,
163+ ca_deathmute_notify_hud_y,
164+ .fadeouttime = 0 .0 ,
165+ .holdtime = ca_deathmute_time - 1 .0
166+ )
167+
168+ static clearedMessage[256 ]
155169
156- if (ca_deathmute_notify_type == notify_HUD) {
157- set_hudmessage (
158- ca_deathmute_notify_hud_r,
159- ca_deathmute_notify_hud_g,
160- ca_deathmute_notify_hud_b,
161- ca_deathmute_notify_hud_x,
162- ca_deathmute_notify_hud_y,
163- .fadeouttime = 0 .0 ,
164- .holdtime = ca_deathmute_time - 1 .0
165- )
166- show_hudmessage (id, " % L" , id, " DeathMute_ChatMessage" , ca_deathmute_time)
170+ formatex (clearedMessage, charsmax (clearedMessage), " % L" , id, " DeathMute_ChatMessage" , ca_deathmute_time)
171+ ReplaceColors (clearedMessage, charsmax (clearedMessage))
172+
173+ ShowSyncHudMsg (id, g_syncHudOj, clearedMessage)
174+ }
167175 }
168176
169177 if (ca_deathmute_notify_show_progressbar) {
@@ -174,25 +182,27 @@ public CBasePlayer_Killed(const id, const attacker) {
174182public DisableSpeakWithAlive (const id) {
175183 g_canSpeakWithAlive[id] = false
176184
177- if (ca_deathmute_notify_type == notify_Disabled) {
178- return
179- }
185+ switch (ca_deathmute_notify_type) {
186+ case notify_Chat: client_print_color (id, print_team_red, " % L % L" , id, " DeathMute_prefix" , id, " DeathMute_YouMuted" )
180187
181- if (ca_deathmute_notify_type == notify_Chat) {
182- client_print_color (id, print_team_red, " % L % L" , id, " DeathMute_prefix" , id, " DeathMute_YouMuted" )
183- }
188+ case notify_HUD: {
189+ set_hudmessage (
190+ ca_deathmute_notify_hud_r,
191+ ca_deathmute_notify_hud_g,
192+ ca_deathmute_notify_hud_b,
193+ ca_deathmute_notify_hud_x,
194+ ca_deathmute_notify_hud_y,
195+ .fadeouttime = 0 .0 ,
196+ .holdtime = ca_deathmute_time - 1 .0
197+ )
184198
185- if (ca_deathmute_notify_type == notify_HUD) {
186- set_hudmessage (
187- ca_deathmute_notify_hud_r,
188- ca_deathmute_notify_hud_g,
189- ca_deathmute_notify_hud_b,
190- ca_deathmute_notify_hud_x,
191- ca_deathmute_notify_hud_y,
192- .fadeouttime = 0 .0 ,
193- .holdtime = ca_deathmute_time - 1 .0
194- )
195- show_hudmessage (id, " % L" , id, " DeathMute_YouMuted" , ca_deathmute_time)
199+ static clearedMessage[256 ]
200+
201+ formatex (clearedMessage, charsmax (clearedMessage), " % L" , id, " DeathMute_YouMuted" , ca_deathmute_time)
202+ ReplaceColors (clearedMessage, charsmax (clearedMessage))
203+
204+ ShowSyncHudMsg (id, g_syncHudOj, clearedMessage)
205+ }
196206 }
197207}
198208
@@ -215,3 +225,9 @@ public CA_Client_Voice(const listener, const sender) {
215225 return CA_CONTINUE
216226}
217227
228+ stock ReplaceColors (text[], len)
229+ {
230+ replace_string (text, len, " \1 " , " " )
231+ replace_string (text, len, " \3 " , " " )
232+ replace_string (text, len, " \4 " , " " )
233+ }
0 commit comments