Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require("command")
- MDA_ChatBox = {}
- MDA_ChatBox.Font = "coolvetica"
- MDA_ChatBox.NewFont = "MDA_ChatBox"
- MDA_ChatBox.FontSize = 14
- MDA_ChatBox.ChatBoxSize = 0.15
- MDA_ChatBox.ChatBox = nil
- MDA_ChatBox.ChatQue = {}
- MDA_ChatBox.SpawnIcon = ""
- surface.CreateFont(MDA_ChatBox.Font, MDA_ChatBox.FontSize, 510, false, false, MDA_ChatBox.NewFont)
- surface.SetFont(MDA_ChatBox.NewFont)
- MDA_ChatBox.TextSizeX, MDA_ChatBox.TextSizeY = surface.GetTextSize("`~!@#$%^&*()_+1234567890-=qQwWeErRtTyYuUiIoOpP[{]}aAsSdDfFgGhHjJkKlL;:'\"zZxXcCvVbBnNmM,<.>/?")
- MDA_ChatBox.EntryDropColor = Color(0,124,210,255)
- local removeIDXs = {}
- function MDA_CreateChatBox()
- local ChatBox = vgui.Create("DTextEntry")
- ChatBox:SetPos(ScrW() * 0.05, ScrH() * 0.95)
- ChatBox:SetSize(ScrW() * 0.35, 15)
- MDA_ChatBox.ChatBox = ChatBox
- end
- function MDA_StartChat(TeamSay)
- if !ValidPanel(MDA_ChatBox.ChatEntry) then
- MDA_CreateChatBox()
- else
- MDA_ChatBox.ChatBox:SetVisible(true)
- end
- gui.EnableScreenClicker(true)
- return true
- end
- hook.Add("StartChat","MDA_StartChat",MDA_StartChat)
- function MDA_FinishChat(TeamSay)
- if ValidPanel(MDA_ChatBox.ChatBox) then
- MDA_ChatBox.ChatBox:SetVisible(false)
- end
- gui.EnableScreenClicker(false)
- end
- hook.Add("FinishChat","MDA_FinishChat",MDA_FinishChat)
- function MDA_ChatTextChanged(text)
- MDA_ChatBox.ChatBox:SetText(text)
- if string.Left(text,1) == "#" then
- MDA_ChatBox.EntryDropColor = Color(255,0,0,255)
- elseif string.Left(text,1) == "$" then
- MDA_ChatBox.EntryDropColor = Color(255,140,0,255)
- else
- MDA_ChatBox.EntryDropColor = Color(0,124,210,255)
- end
- end
- hook.Add("ChatTextChanged","MDA_ChatTextChanged",MDA_ChatTextChanged)
- function MDA_ChatTextAddQue(ply, text, teamchat, alive)
- if ply == LocalPlayer() and string.sub(text,1,9) == "#fontsize" then
- MDA_ChatBox.FontSize = tonumber(string.sub(text,11))
- RunConsoleCommand("gm_clearfonts")
- command.ServerCommand("lua_run_cl surface.CreateFont(\""..MDA_ChatBox.Font.."\", "..MDA_ChatBox.FontSize..", 400, false, false, \"MDA_ChatBox\")\n")
- surface.SetFont(MDA_ChatBox.NewFont)
- MDA_ChatBox.TextSizeX, MDA_ChatBox.TextSizeY = surface.GetTextSize("`~!@#$%^&*()_+1234567890-=qQwWeErRtTyYuUiIoOpP[{]}aAsSdDfFgGhHjJkKlL;:'\"zZxXcCvVbBnNmM,<.>/?")
- end
- if ply == LocalPlayer() and string.sub(text,1,5) == "#font" then
- MDA_ChatBox.Font = string.sub(text,7)
- RunConsoleCommand("gm_clearfonts")
- command.ServerCommand("lua_run_cl surface.CreateFont(\""..MDA_ChatBox.Font.."\", "..MDA_ChatBox.FontSize..", 400, false, false, \"MDA_ChatBox\")\n")
- surface.SetFont(MDA_ChatBox.NewFont)
- MDA_ChatBox.TextSizeX, MDA_ChatBox.TextSizeY = surface.GetTextSize("`~!@#$%^&*()_+1234567890-=qQwWeErRtTyYuUiIoOpP[{]}aAsSdDfFgGhHjJkKlL;:'\"zZxXcCvVbBnNmM,<.>/?")
- end
- if ply == LocalPlayer() and string.sub(text,1,5) == "#size" then
- MDA_ChatBox.ChatBoxSize = tonumber(string.sub(text,7))
- end
- if ply == LocalPlayer() and string.Left(text,1) == "$" then
- command.ServerCommand(string.sub(text,2).."\n")
- end
- table.insert(MDA_ChatBox.ChatQue, {CurTime(),ply,alive,teamchat,text,Color(255,255,255,255)})
- end
- hook.Add("OnPlayerChat","MDA_ChatTextAddQue",MDA_ChatTextAddQue)
- function MDA_ChatBox_PlayerConnect(name, ip, sid)
- local text = "Player "..name.." has joined the server. ["..ip..", "..sid.."]"
- table.insert(MDA_ChatBox.ChatQue {CurTime(),"PlyConnect",text,Color(0,0,255,255)})
- end
- hook.Add("PlayerConnect", "MDA_ChatBox_PlayerConnect", MDA_ChatBox_PlayerConnect)
- function MDA_ChatBox_Nofity_JoinLeave(ply, name, text, mtype)
- if mtype == "joinleave" then
- table.insert(MDA_ChatBox.ChatQue, {CurTime(),"PlyJoinLeave",text,Color(0,0,255,255)})
- elseif mtype == "none" then
- if string.sub(text,1,22) == "Generated Spawn Icon (" then
- MDA_ChatBox.SpawnIcon = text
- if string.sub(1,23) == "Generated Spawn Icon (0" then
- timer.Simple(0.4, function() MDA_ChatBox.SpawnIcon = "" end)
- end
- else
- table.insert(MDA_ChatBox.ChatQue, {CurTime(),"Notify",text,Color(0,0,200,255)})
- end
- end
- end
- hook.Add("ChatText", "MDA_ChatBox_Nofity_JoinLeave", MDA_ChatBox_Nofity_JoinLeave)
- function MDA_ChatBoxDraws()
- local t_x, t_y, t_w, t_h
- if ValidPanel(MDA_ChatBox.ChatBox) then
- rt_x, rt_y = MDA_ChatBox.ChatBox:GetPos()
- t_x, t_y = MDA_ChatBox.ChatBox:GetPos()
- t_x = t_x + ScrW() * 0.004
- t_y = t_y + ScrH() * 0.004
- t_w, t_h = MDA_ChatBox.ChatBox:GetSize()
- if MDA_ChatBox.ChatBox:IsVisible() then
- draw.RoundedBox(4, t_x, t_y, t_w, t_h, MDA_ChatBox.EntryDropColor)
- rt_x, rt_y = MDA_ChatBox.ChatBox:GetPos()
- t_x, t_y = MDA_ChatBox.ChatBox:GetPos()
- t_y = t_y - ScrW() * MDA_ChatBox.ChatBoxSize
- surface.SetDrawColor(255, 0, 0, 255)
- surface.DrawLine(t_x - 3, t_y, t_x - 3 + t_w + ScrW() * 0.004 + 2, t_y)
- surface.DrawLine(t_x - 3, rt_y - 2, t_x - 3 + t_w + ScrW() * 0.004 + 2, rt_y - 2)
- surface.DrawLine(t_x - 3 + t_w + ScrW() * 0.004 + 2, t_y, t_x-3 + t_w + ScrW() * 0.004 + 2, rt_y - 2)
- surface.DrawLine(t_x - 3, t_y, t_x - 3, rt_y - 2)
- end
- end
- --Actual chat
- if ValidPanel(MDA_ChatBox.ChatBox) then
- rt_x, rt_y = MDA_ChatBox.ChatBox:GetPos()
- t_x, t_y = MDA_ChatBox.ChatBox:GetPos()
- t_y = t_y - ScrW() * MDA_ChatBox.ChatBoxSize
- removeIDXs = {}
- for idx,info in pairs(MDA_ChatBox.ChatQue) do
- if CurTime() <= info[1] + 4 then
- if pcall(function()
- surface.SetFont(MDA_ChatBox.NewFont)
- local namesizex, namesizey = surface.GetTextSize(info[2]:Nick()..": ")
- draw.DrawText(info[2]:Nick()..": ", MDA_ChatBox.NewFont, t_x, t_y + (MDA_ChatBox.TextSizeY * (idx - 1)), team.GetColor(info[2]:Team()), TEXT_ALIGN_LEFT)
- draw.DrawText(info[5], MDA_ChatBox.NewFont, t_x + namesizex, t_y + (MDA_ChatBox.TextSizeY * (idx - 1)), info[6], TEXT_ALIGN_LEFT) end)
- then
- --Do nothing
- else
- if info[2] == "PlyJoinLeave" then
- draw.DrawText(info[3], MDA_ChatBox.NewFont, t_x, t_y + (MDA_ChatBox.TextSizeY * (idx - 1)), info[4], TEXT_ALIGN_LEFT)
- elseif info[2] == "Notify" then
- draw.DrawText(info[3], MDA_ChatBox.NewFont, t_x, t_y + (MDA_ChatBox.TextSizeY * (idx - 1)), info[4], TEXT_ALIGN_LEFT)
- end
- end
- else
- table.insert(removeIDXs, idx)
- end
- --print(-(t_y-rt_y-2),MDA_ChatBox.TextSizeY,math.floor(-(t_y-rt_y-2) / MDA_ChatBox.TextSizeY))
- if idx == math.floor(-(t_y-rt_y-2) / MDA_ChatBox.TextSizeY) then
- table.remove(MDA_ChatBox.ChatQue, 1)
- end
- surface.SetDrawColor(255, 0, 0, 255)
- surface.DrawLine(t_x - 3, t_y, t_x - 3 + t_w + ScrW() * 0.004 + 2, t_y)
- surface.DrawLine(t_x - 3, rt_y - 2, t_x - 3 + t_w + ScrW() * 0.004 + 2, rt_y - 2)
- surface.DrawLine(t_x - 3 + t_w + ScrW() * 0.004 + 2, t_y, t_x-3 + t_w + ScrW() * 0.004 + 2, rt_y - 2)
- surface.DrawLine(t_x - 3, t_y, t_x - 3, rt_y - 2)
- end
- if MDA_ChatBox.SpawnIcon ~= "" then
- draw.DrawText(MDA_ChatBox.SpawnIcon, MDA_ChatBox.NewFont, t_x, t_y - MDA_ChatBox.TextSizeY, Color(0,128,128,255), TEXT_ALIGN_LEFT)
- end
- for i,idxToRem in pairs(removeIDXs) do
- table.remove(MDA_ChatBox.ChatQue, idxToRem)
- end
- end
- end
- hook.Add("HUDPaint","MDAChatBox",MDA_ChatBoxDraws)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement