Загрузка данных
-- cl_chat.lua
-- Кастомный чат kdm1eHvH (замена DarkRP-чата)
-- ============================================================
-- Gamemode function
-- ============================================================
function GM:OnPlayerChat()
end
-- ============================================================
-- Настройки чата
-- ============================================================
local MAX_MESSAGES = 9
local FADE_TIME = 5
local FADE_OUT = 1
local LINE_HEIGHT = 26
local BOX_WIDTH = 560
local MARGIN_X = 20
local MARGIN_Y = 20
local ACCENT = Color(220, 40, 40)
local BG = Color(10, 10, 15, 220)
local TEXT = Color(235, 235, 235)
local RANK_LIST = {
["user"] = { color = Color(180, 180, 180), name = "User" },
["beta_tester"] = { color = Color(80, 220, 220), name = "Beta Tester" },
["vip"] = { color = Color(255, 200, 50), name = "VIP" },
["moderator"] = { color = Color(80, 150, 255), name = "Moderator" },
["admin"] = { color = Color(255, 70, 70), name = "Admin" },
["senior_admin"] = { color = Color(200, 30, 30), name = "Senior Admin" },
["manager"] = { color = Color(180, 80, 255), name = "Manager" },
["superadmin"] = { color = Color(255, 130, 0), name = "Superadmin" },
}
surface.CreateFont("chat_hud_text", { font = "Montserrat", size = 17, weight = 500, extended = true })
surface.CreateFont("chat_hud_bold", { font = "Montserrat", size = 17, weight = 800, extended = true })
-- ============================================================
-- Хранилище сообщений
-- ============================================================
local messages = {}
local lastMessageTime = 0
local function AddMessage(data)
table.insert(messages, data)
while #messages > MAX_MESSAGES do
table.remove(messages, 1)
end
lastMessageTime = CurTime()
end
-- ============================================================
-- Перехват DarkRP-чата
-- ============================================================
local function AddToChat(bits)
local col1 = Color(net.ReadUInt(8), net.ReadUInt(8), net.ReadUInt(8))
local prefixText = net.ReadString()
local ply = net.ReadEntity()
ply = IsValid(ply) and ply or LocalPlayer()
if not IsValid(ply) then return end
if prefixText == "" or not prefixText then
prefixText = ply:Nick()
prefixText = prefixText ~= "" and prefixText or ply:SteamName()
end
local col2 = Color(net.ReadUInt(8), net.ReadUInt(8), net.ReadUInt(8))
local text = net.ReadString()
local shouldShow
if text and text ~= "" then
if IsValid(ply) then
shouldShow = hook.Call("OnPlayerChat", GAMEMODE, ply, text, false, not ply:Alive(), prefixText, col1, col2)
end
if shouldShow ~= true then
-- Добавляем в НАШ чат
local rank = ply:GetNWString("kdm1e_Rank", "user")
local rankData = RANK_LIST[rank] or RANK_LIST["user"]
AddMessage({
type = "player",
nick = prefixText,
text = text,
rankName = (rank ~= "user") and rankData.name or nil,
rankColor = rankData.color,
})
end
else
shouldShow = hook.Call("ChatText", GAMEMODE, "0", prefixText, prefixText, "darkrp")
if shouldShow ~= true then
AddMessage({
type = "system",
text = prefixText,
})
end
end
chat.PlaySound()
end
net.Receive("DarkRP_Chat", AddToChat)
-- ============================================================
-- Отрисовка чата
-- ============================================================
local function DrawChat()
if #messages == 0 then return end
local now = CurTime()
local since = now - lastMessageTime
if since > FADE_TIME + FADE_OUT then
messages = {}
return
end
local alpha = 255
if since > FADE_TIME then
alpha = 255 * (1 - (since - FADE_TIME) / FADE_OUT)
end
local count = #messages
local totalH = count * LINE_HEIGHT + 16
local startY = ScrH() - MARGIN_Y - totalH
local startX = MARGIN_X
surface.SetDrawColor(BG.r, BG.g, BG.b, BG.a * (alpha / 255))
surface.DrawRect(startX, startY, BOX_WIDTH, totalH)
surface.SetDrawColor(ACCENT.r, ACCENT.g, ACCENT.b, alpha)
surface.DrawRect(startX, startY, 3, totalH)
for i, msg in ipairs(messages) do
local y = startY + 8 + (i - 1) * LINE_HEIGHT
if msg.type == "player" then
local x = startX + 14
if msg.rankName then
local prefix = "[" .. msg.rankName .. "] "
local pc = Color(msg.rankColor.r, msg.rankColor.g, msg.rankColor.b, alpha)
surface.SetFont("chat_hud_bold")
draw.SimpleText(prefix, "chat_hud_bold", x, y, pc, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
x = x + surface.GetTextSize(prefix)
end
local nickText = msg.nick .. ": "
surface.SetFont("chat_hud_bold")
draw.SimpleText(nickText, "chat_hud_bold", x, y, Color(255, 255, 255, alpha), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
x = x + surface.GetTextSize(nickText)
surface.SetFont("chat_hud_text")
draw.SimpleText(msg.text, "chat_hud_text", x, y, Color(TEXT.r, TEXT.g, TEXT.b, alpha), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
else
local x = startX + 14
surface.SetFont("chat_hud_text")
draw.SimpleText(msg.text, "chat_hud_text", x, y, Color(TEXT.r, TEXT.g, TEXT.b, alpha), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
end
end
end
hook.Add("HUDPaint", "ChatHUD_kdm1eHvH_Draw", DrawChat)
-- ============================================================
-- Скрываем стандартный чат GMod
-- ============================================================
hook.Add("HUDShouldDraw", "HideDefaultChat_kdm1eHvH", function(name)
if name == "CHudChat" then return false end
end)
-- ============================================================
-- Credits (без изменений)
-- ============================================================
local creds =
[[
LightRP was created by Rick darkalonio. LightRP was sandbox with some added RP elements.
LightRP was released at the end of January 2007
DarkRP was created as a spoof of LightRP by Rickster, somewhere during the summer of 2007.
Note: There was a DarkRP in 2006, but that was an entirely different gamemode.
Rickster went to serve his country and went to Afghanistan. During that time, the following people updated DarkRP:
Picwizdan
Sibre
[GNC] Matt
PhilXYZ
Chromebolt A.K.A. Unib5 (STEAM_0:1:19045957)
In 2008, Unib5 was administrator on a DarkRP server called EuroRP, owned by Jiggu. FPtje frequently joined this server to prop kill en masse. While Jiggu loved watching the chaos unfold, Unib5 hated it and banned FPtje on sight. Since Jiggu kept unbanning FPtje, Unib5 felt powerless. In an attempt to stop FPtje, Unib5 put FPtje's favourite prop killing props (the locker and the sawblade) in the default blacklist of DarkRP in an update. This in turn enraged FPtje, as he swore to make an update in secret that would suddenly pop up and overthrow the established version. As a result, DarkRP 2.3.1 was released in December 2008. After a bit of a fight, FPtje became the official updater of DarkRP.
Current developer:
Falco A.K.A. FPtje Atheos (STEAM_0:0:8944068)
People who have contributed (ordered by commits, with at least two commits)
Bo98
Drakehawke (STEAM_0:0:22342869) (64 commits on old SVN)
FiG-Scorn
Noiwex
KoZ
Eusion (STEAM_0:0:20450406) (3 commits on old SVN)
Gangleider
MattWalton12
TypicalRookie
]]
local function credits(um)
chat.AddNonParsedText(Color(255, 0, 0, 255), "[", Color(50,50,50,255), GAMEMODE.Name, Color(255, 0, 0, 255), "] ", color_white, DarkRP.getPhrase("credits_see_console"))
MsgC(Color(255, 0, 0, 255), DarkRP.getPhrase("credits_for", GAMEMODE.Name), color_white, creds)
end
usermessage.Hook("DarkRP_Credits", credits)