Skip to content
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
4 changes: 4 additions & 0 deletions gamemode/config/sh_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ nut.config.add("loocDelayAdmin", false, "Whether or not LOOC chat delay is enabl
category = "chat"
})

nut.config.add("chatShowTime", false, "Whether or not to show timestamps in front of chat messages.", nil, {
category = "chat"
})

nut.config.add("spawnTime", 5, "The time it takes to respawn.", nil, {
data = {min = 0, max = 10000},
category = "characters"
Expand Down
12 changes: 9 additions & 3 deletions gamemode/core/libs/sh_chatbox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ if (!nut.command) then
include("sh_command.lua")
end

-- Returns a timestamp
function nut.chat.timestamp(ooc)
return nut.config.get("chatShowTime") and (ooc and " " or "").."("..nut.date.getFormatted("%H:%M")..")"..(ooc and "" or " ") or ""
end

-- Registers a new chat type with the information provided.
function nut.chat.register(chatType, data)
if (!data.onCanHear) then
Expand Down Expand Up @@ -52,9 +57,10 @@ function nut.chat.register(chatType, data)
color = data.onGetColor(speaker, text)
end

local timestamp = nut.chat.timestamp(false)
local translated = L2(chatType.."Format", name, text)

chat.AddText(color, translated or string.format(data.format, name, text))
chat.AddText(timestamp, color, translated or timestamp..string.format(data.format, name, text))
end
end

Expand Down Expand Up @@ -303,7 +309,7 @@ do

icon = Material(hook.Run("GetPlayerIcon", speaker) or icon)

chat.AddText(icon, Color(255, 50, 50), " [OOC] ", speaker, color_white, ": "..text)
chat.AddText(icon, nut.chat.timestamp(true), Color(255, 50, 50), " [OOC] ", speaker, color_white, ": "..text)
end,
prefix = {"//", "/ooc"},
noSpaceAfter = true,
Expand Down Expand Up @@ -334,7 +340,7 @@ do
speaker.nutLastLOOC = CurTime()
end,
onChatAdd = function(speaker, text)
chat.AddText(Color(255, 50, 50), "[LOOC] ", nut.config.get("chatColor"), speaker:Name()..": "..text)
chat.AddText(nut.chat.timestamp(false), Color(255, 50, 50), "[LOOC] ", nut.config.get("chatColor"), speaker:Name()..": "..text)
end,
onCanHear = nut.config.get("chatRange", 280),
prefix = {".//", "[[", "/looc"},
Expand Down