Initial commit

This commit is contained in:
pavetr
2026-03-15 14:54:49 +03:00
commit 64f8029c06
4027 changed files with 254888 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
--[[---------------------------------------------------------------------------
Log a message to console
---------------------------------------------------------------------------]]
local function AdminLog(um)
local colour = Color(um:ReadShort(), um:ReadShort(), um:ReadShort())
local text = DarkRP.deLocalise(um:ReadString() .. "\n")
MsgC(Color(255, 0, 0), "[" .. GAMEMODE.Name .. "] ", colour, text)
hook.Call("DarkRPLogPrinted", nil, text, colour)
end
usermessage.Hook("DRPLogMsg", AdminLog)
--[[---------------------------------------------------------------------------
Interface
---------------------------------------------------------------------------]]
DarkRP.hookStub{
name = "DarkRPLogPrinted",
description = "Called when a log has printed in console.",
realm = "Client",
parameters = {
{
name = "text",
description = "The actual log.",
type = "string"
},
{
name = "colour",
description = "The colour of the printed log.",
type = "Color"
}
},
returns = {}
}

View File

@@ -0,0 +1,26 @@
DarkRP.log = DarkRP.stub{
name = "log",
description = "Log a message in DarkRP",
parameters = {
{
name = "message",
description = "The message to log",
type = "string",
optional = false
},
{
name = "colour",
description = "The color of the message in the admin's console. Admins won't see the message if this is not defined.",
type = "Color",
optional = true
},
{
name = "noFileSave",
description = "Whether to write the log to a file or not.",
type = "boolean",
optional = true
}
},
returns = {},
metatable = DarkRP
}

View File

@@ -0,0 +1,37 @@
local function AdminLog(message, colour, allowedPlys)
local RF = RecipientFilter()
for _, v in pairs(allowedPlys) do
local canHear = hook.Call("canSeeLogMessage", GAMEMODE, v, message, colour)
if canHear then
RF:AddPlayer(v)
end
end
umsg.Start("DRPLogMsg", RF)
umsg.Short(colour.r)
umsg.Short(colour.g)
umsg.Short(colour.b) -- Alpha is not needed
umsg.String(message)
umsg.End()
end
local DarkRPFile
function DarkRP.log(text, colour, noFileSave)
if colour then
CAMI.GetPlayersWithAccess("DarkRP_SeeEvents", fp{AdminLog, text, colour})
end
if not GAMEMODE.Config.logging or noFileSave then return end
if not DarkRPFile then -- The log file of this session, if it's not there then make it!
if not file.IsDir("darkrp_logs", "DATA") then
file.CreateDir("darkrp_logs")
end
DarkRPFile = "darkrp_logs/" .. os.date("%m_%d_%Y %I_%M %p") .. ".txt"
file.Write(DarkRPFile, os.date() .. "\t" .. text)
return
end
file.Append(DarkRPFile, "\n" .. os.date() .. "\t" .. (text or ""))
end