Files
Bubberstation/code/modules/admin/verbs/deadsay.dm
Watermelon914 375a20e49b Refactors most spans into span procs (#59645)
Converts most spans into span procs. Mostly used regex for this and sorted out any compile time errors afterwards so there could be some bugs.
Was initially going to do defines, but ninja said to make it into a proc, and if there's any overhead, they can easily be changed to defines.

Makes it easier to control the formatting and prevents typos when creating spans as it'll runtime if you misspell instead of silently failing.
Reduces the code you need to write when writing spans, as you don't need to close the span as that's automatically handled by the proc.

(Note from Lemon: This should be converted to defines once we update the minimum version to 514. Didn't do it now because byond pain and such)
2021-06-14 13:03:53 -07:00

44 lines
1.5 KiB
Plaintext

/client/proc/dsay(msg as text)
set category = "Admin.Game"
set name = "Dsay"
set hidden = TRUE
if(!holder)
to_chat(src, "Only administrators may use this command.", confidential = TRUE)
return
if(!mob)
return
if(prefs.muted & MUTE_DEADCHAT)
to_chat(src, span_danger("You cannot send DSAY messages (muted)."), confidential = TRUE)
return
if (handle_spam_prevention(msg,MUTE_DEADCHAT))
return
msg = copytext_char(sanitize(msg), 1, MAX_MESSAGE_LEN)
mob.log_talk(msg, LOG_DSAY)
if (!msg)
return
var/rank_name = holder.rank
var/admin_name = key
if(holder.fakekey)
rank_name = pick(strings("admin_nicknames.json", "ranks", "config"))
admin_name = pick(strings("admin_nicknames.json", "names", "config"))
var/rendered = "<span class='game deadsay'>[span_prefix("DEAD:")] [span_name("[rank_name]([admin_name])")] says, <span class='message'>\"[emoji_parse(msg)]\"</span></span>"
for (var/mob/M in GLOB.player_list)
if(isnewplayer(M))
continue
if (M.stat == DEAD || (M.client.holder && (M.client.prefs.chat_toggles & CHAT_DEAD))) //admins can toggle deadchat on and off. This is a proc in admin.dm and is only give to Administrators and above
to_chat(M, rendered, confidential = TRUE)
SSblackbox.record_feedback("tally", "admin_verb", 1, "Dsay") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/get_dead_say()
var/msg = input(src, null, "dsay \"text\"") as text|null
if (isnull(msg))
return
dsay(msg)