37 lines
1.1 KiB
Lua
37 lines
1.1 KiB
Lua
|
local ENABLED = CreateClientConVar("cbox_timestamps", "1", true, false, "Enables timestamps", 0, 1)
|
||
|
local TRUETIME = CreateClientConVar("cbox_timestamps_24hr", "1", true, false, "Whether timestamps should be 24 hour instead of 12 hour", 0, 1)
|
||
|
local SECONDS = CreateClientConVar("cbox_timestamps_seconds", "0", true, false, "Whether timestamps should display seconds", 0, 1)
|
||
|
local COLOR = CreateClientConVar("cbox_timestamps_color", "151 211 255", true, false, "Color timestamps should be")
|
||
|
|
||
|
local color_white = Color(255, 255, 255)
|
||
|
|
||
|
cbox.hooks.Add("PreChatAddText", "cbox.timestamps", function(args)
|
||
|
if not ENABLED:GetBool() then return end
|
||
|
|
||
|
local use24 = TRUETIME:GetBool()
|
||
|
local stamp = ""
|
||
|
|
||
|
if use24 then
|
||
|
stamp = stamp .. os.date("%H:")
|
||
|
else
|
||
|
stamp = stamp .. os.date("%I:")
|
||
|
end
|
||
|
|
||
|
stamp = stamp .. os.date("%M")
|
||
|
|
||
|
if SECONDS:GetBool() then
|
||
|
stamp = stamp .. os.date(":%S")
|
||
|
end
|
||
|
|
||
|
if not use24 then
|
||
|
stamp = stamp .. os.date(" %p")
|
||
|
end
|
||
|
|
||
|
local new_args = {cbox.utils.ParseColorString(COLOR:GetString()), stamp, color_white, " - "}
|
||
|
for _, arg in ipairs(args) do
|
||
|
new_args[#new_args + 1] = arg
|
||
|
end
|
||
|
|
||
|
return new_args
|
||
|
end)
|