1
0
mirror of https://github.com/Earu/EasyChat.git synced 2025-03-04 03:13:20 -05:00
This commit is contained in:
Earu 2017-06-30 20:19:10 +02:00
parent c3e08df630
commit 27b82d691a
17 changed files with 1077 additions and 441 deletions

View File

@ -1,19 +1,2 @@
# EasyChat is a Garry's Mod addon, it replaces the default souce chat and adds many features.
- Fully customizable colors and font
- Various options like timestamps etc
- Private messages system integrated
- Modular system
## For developers here's the good news:
Easychat is a modular addon, you can make modules for it very easily.
Remember those little scripts that are just about using OnPlayerChat hook or PlayerSay?
Just place them inside easychat/modules and there you go, finally a place to sort things where they belong.
You can also create vgui for EasyChat very easily, make a DPanel that will be parent of your vgui then you can add it to EasyChat frame like so: EasyChat.AddTab("tabnamehere",panelhere) and tada.
### note: The current repository has modules in it you might want to remove them in your installation unless you have the dependancies required for them
# EasyChat [![Build Status](https://travis-ci.org/PAC3-Server/EasyChat.svg?branch=master)](https://travis-ci.org/PAC3-Server/EasyChat)
The chat we use for the server

View File

@ -0,0 +1,75 @@
if not EasyChat then return end
EasyChat.Modules = {}
EasyChat.LoadModules = function()
local path = "easychat/modules/"
local pline = "-----------------------------------------------"
print(pline)
local propername = function(arg)
if type(arg) == "string" then
return arg
else
return nil
end
end
for _,file_name in pairs((file.Find(path.."*.lua","LUA"))) do
AddCSLuaFile(path..file_name)
local module = CompileFile(path..file_name)
local succ,err = pcall(module)
if succ then
table.insert(EasyChat.Modules,{
Name = propername(err) and propername(err) or "",
File = file_name,
Callback = module,
})
print("[ECModule] ⮞ "..(propername(err) and propername(err) or file_name).." mounted")
else
print("[ECModule] ⮞ Couldn't mount "..file_name.."\n "..err)
end
end
if SERVER then
for _,file_name in pairs((file.Find(path.."server/*.lua","LUA"))) do
local module = CompileFile(path.."server/"..file_name)
local succ,err = pcall(module)
if succ then
table.insert(EasyChat.Modules,{
Name = propername(err) and propername(err) or "",
File = file_name,
Callback = module,
})
print("[ECModule] ⮞ "..(propername(err) and propername(err) or file_name).." mounted")
else
print("[ECModule] ⮞ Couldn't mount "..file_name.."\n "..err)
end
end
for _,file_name in pairs((file.Find(path.."client/*.lua","LUA"))) do
AddCSLuaFile(path.."client/"..file_name)
end
end
if CLIENT then
for _,file_name in pairs((file.Find(path.."client/*.lua","LUA"))) do
local module = CompileFile(path.."client/"..file_name)
local succ,err = pcall(module)
if succ then
table.insert(EasyChat.Modules,{
Name = propername(err) and propername(err) or "",
File = file_name,
Callback = module,
})
print("[ECModule] ⮞ "..(propername(err) and propername(err) or file_name).." mounted")
else
print("[ECModule] ⮞ Couldn't mount "..file_name.."\n "..err)
end
end
end
print(pline)
end

File diff suppressed because it is too large Load Diff

View File

@ -2,13 +2,13 @@ local netstring = "EASY_CHAT_AFK"
if SERVER then
util.AddNetworkString(netstring)
local GetAFKTime = function(ply)
if ply:IsAFK() and ply.afk_at_time then
if ply:IsAFK() and ply.afk_at_time then
return RealTime() - ply.afk_at_time
else
return 0
end
end
end
hook.Add("OnPlayerAFK","EasyChat",function(ent,afk)
@ -28,9 +28,11 @@ if CLIENT then
local afk = net.ReadBool()
local time = net.ReadFloat()
if afk then
chat.AddText(Color(255,20,20),"",Color(255,255,255),ply:GetName().." is now ",Color(255,20,20),"away")
chat.AddText(Color(209,62,57),"",Color(200,200,200),ply:GetName().." is now ",Color(209,62,57),"away")
else
chat.AddText(Color(20,255,20),"",Color(255,255,255),ply:GetName().." is now ",Color(20,255,20),"back",Color(220,220,220)," (away for "..string.NiceTime(time)..")")
chat.AddText(Color(92,184,92),"",Color(200,200,200),ply:GetName().." is now ",Color(92,184,92),"back",Color(175,175,175)," (away for "..string.NiceTime(time)..")")
end
end)
end
return "AFK Notifications"

View File

@ -1,38 +1,44 @@
---lua chat beautify---
local LuaChat = {}
local blue = Color(102, 217, 239)
local orange = Color(166, 226, 46)
local red = Color(244, 66, 66)
local blue = Color(132, 182, 232)
local orange = Color(188, 161, 98)
local red = Color(140, 101, 211)
LuaChat.Cmds = {
["l"] = {text = "Server", color = blue },
["lm"] = {text = "Self", color = red },
["ls"] = {text = "Shared", color = orange },
["lb"] = {text = "Both", color = orange },
["lc"] = {text = "Clients", color = red },
["print"] = {text = "Server Print", color = blue },
["table"] = {text = "Server Table", color = blue },
["keys"] = {text = "Server Keys", color = blue },
["printm"] = {text = "Self Print", color = red },
["printb"] = {text = "Both Print", color = orange },
["printc"] = {text = "Clients Print", color = red },
["cmd"] = {text = "Console", color = red },
["rcon"] = {text = "Server Console", color = blue },
["settod"] = {text = "Tod", color = blue },
["element"] = {text = "Element", color = blue },
["g"] = {text = "Google", color = red },
["go"] = {text = "Goto", color = red },
["goto"] = {text = "Goto", color = red },
["level"] = {text = "Level Up", color = red },
["sudo"] = {text = "Sudo", color = blue },
["find"] = {text = "Server Find", color = blue },
["p"] = {text = "Server Find", color = blue },
["map"] = {text = "Map", color = blue },
["restart"] = {text = "Server Restart", color = blue },
["reboot"] = {text = "Server Reboot", color = blue },
["mfind"] = {text = "Self Find", color = red },
["mp"] = {text = "Self Find", color = red },
["wear"] = {text = "PAC3 Wear", color = red },
["l"] = {text = "Server", color = blue },
["lm"] = {text = "Self", color = red },
["ls"] = {text = "Shared", color = orange },
["lb"] = {text = "Both", color = orange },
["lc"] = {text = "Clients", color = red },
["print"] = {text = "Server Print", color = blue },
["table"] = {text = "Server Table", color = blue },
["keys"] = {text = "Server Keys", color = blue },
["printm"] = {text = "Self Print", color = red },
["printb"] = {text = "Both Print", color = orange },
["printc"] = {text = "Clients Print", color = red },
["cmd"] = {text = "Console", color = red },
["rcon"] = {text = "Server Console", color = blue },
["settod"] = {text = "Tod", color = blue },
["element"] = {text = "Element", color = blue },
["g"] = {text = "Google", color = red },
["go"] = {text = "Goto", color = red },
["goto"] = {text = "Goto", color = red },
["bring"] = {text = "Bring", color = red },
["level"] = {text = "Level Up", color = red },
["sudo"] = {text = "Sudo", color = blue },
["find"] = {text = "Server Find", color = blue },
["p"] = {text = "Server Find", color = blue },
["map"] = {text = "Map", color = blue },
["restart"] = {text = "Server Restart", color = blue },
["reboot"] = {text = "Server Reboot", color = blue },
["resetmap"] = {text = "Server Cleanup", color = blue },
["cleanuo"] = {text = "Server Cleanup", color = blue },
["mfind"] = {text = "Self Find", color = red },
["mp"] = {text = "Self Find", color = red },
["wear"] = {text = "PAC3 Wear", color = red },
["ignorepac"] = {text = "PAC3 Ignore", color = red },
["unignorepac"] = {text = "PAC3 UnIgnore", color = red },
["ytplay"] = {text = "Youtube", color = blue },
}
@ -43,6 +49,7 @@ LuaChat.OnClientCmds = { --add commands ran on specific client here
["kick"] = "Kick",
["rank"] = "Rank",
["give"] = "Give",
["exit"] = "Exit",
}
LuaChat.IsCommand = function(str)
@ -56,7 +63,11 @@ local function get(str)
if not str then return "" end
if player.FindByName then
return player.FindByName(str):GetName()
if IsValid(player.FindByName(str)) then
return player.FindByName(str)
else
return str
end
else
return str
end
@ -76,7 +87,6 @@ LuaChat.DoLuaCommand = function(ply,str)
local str,_ = string.gsub(str,"^[!|%.|/]","")
local args = string.Explode(" ",str)
local cmd = string.lower(args[1])
local team_color = team.GetColor(ply:Team())
local line = ""
@ -85,8 +95,6 @@ LuaChat.DoLuaCommand = function(ply,str)
line = table.concat(args," ",2)
chatText(team_color, ply, line, LuaChat.Cmds[cmd])
return true
elseif LuaChat.OnClientCmds[cmd] then
local a = string.Explode(",",args[2])
@ -96,10 +104,16 @@ LuaChat.DoLuaCommand = function(ply,str)
chatText(team_color, ply, line, cmd, get(a[1]), a[2])
return true
end
return true
end
if string.match(string.lower(str),"^!menu") and ply == LocalPlayer() then
chat.AddText(Color(255,255,255),"Sorry this server doesnt use ULX!")
return true
end
end
hook.Add("OnPlayerChat","LuaChatCommands",LuaChat.DoLuaCommand)
return "Better AOWL Chat Commands"

View File

@ -1,3 +1,23 @@
if hook.GetTable().ChatsoundsUpdated and hook.GetTable().ChatsoundsUpdated.EasyChatModuleChatsoundsDocking then
chatgui = EasyChat.ChatBox
end
hook.Add("ChatsoundsUpdated","EasyChatModuleChatsoundsDocking",function()
chatgui = EasyChat.ChatBox
end)
end)
cvars.AddChangeCallback("easychat_enable",function(name,old,new)
if chatsounds then
if GetConVar(name):GetBool() then
chatgui = EasyChat.ChatBox
else
chatgui = nil
end
end
end)
EasyChat.AddMode("Chatsound",function(text)
LocalPlayer():ConCommand("saysound "..text)
end)
return "Chatsounds"

View File

@ -0,0 +1,44 @@
hook.Add("OnPlayerChat","EasyChatModuleGreenText",function(ply,txt)
if string.match(txt,"^>") then
chat.AddText(ply,Color(255,255,255),": ",Color(0,255,0),txt)
return true
end
end)
local stored = {}
local store = function(ply,txt)
if #stored >= 10 then
table.remove(stored,#stored)
end
table.insert(stored,1,{
Player = ply,
Content = txt,
})
end
hook.Add("OnPlayerChat","EasyChatModuleSed",function(ply,txt)
if string.match(txt,"^s%/.+%/.+") then
local args = string.Explode("/",txt)
local toreplace
if not args[2] or not args[3] then return end
for k,v in pairs(stored) do
if string.match(v.Content,args[2]) and IsValid(v.Player) then
toreplace = v
break
end
end
if toreplace then
local replaced = string.Replace(toreplace.Content,args[2],args[3])
if toreplace.Player ~= ply then
chat.AddText(ply,Color(255,255,255)," thinks ",toreplace.Player,Color(255,255,255)," meant: "..replaced)
else
chat.AddText(ply,Color(255,255,255)," meant: "..replaced)
end
return true
end
else
store(ply,txt)
end
end)
return "Generic Chat Things"

View File

@ -0,0 +1,49 @@
if EasyChat.LocalMessagePanel then
EasyChat.LocalMessagePanel:Remove()
end
local panel = vgui.Create("DFrame")
panel:SetTitle("")
panel.btnClose:Hide()
panel.btnMaxim:Hide()
panel.btnMinim:Hide()
panel.Think = function(self)
local x,y,w,h = EasyChat.ChatBox:GetBounds()
self:SetPos(x + w,y)
end
panel:SetWide(150)
panel.old_paint = panel.Paint
panel.Paint = function(self,w,h)
if EasyChat.IsOpened() and EasyChat.Modes[EasyChat.Mode] and EasyChat.Modes[EasyChat.Mode].Name == "Local" then
if EasyChat.UseDermaSkin then
self.old_paint(self,w,h)
else
surface.SetDrawColor(EasyChat.OutlayColor)
surface.DrawRect(0,0,w,h)
surface.SetDrawColor(EasyChat.OutlayOutlineColor)
surface.DrawOutlinedRect(0,0,w,h)
end
surface.SetFont("EasyChatFont")
surface.SetTextPos(15,5)
surface.SetTextColor(EasyChat.TextColor)
surface.DrawText("Message receivers")
local index = 1
for k,v in pairs(player.GetAll()) do
if v ~= LocalPlayer() and v:GetPos():Distance(LocalPlayer():GetPos()) <= GetConVar("easychat_local_msg_distance"):GetInt() then
surface.SetTextPos(15,25*index)
local col = team.GetColor(v:Team())
surface.SetTextColor(col.r,col.g,col.g,255)
local x,y = surface.GetTextSize(v:GetName())
self:SetTall((25 * index) + y + 10)
surface.DrawText(v:GetName())
index = index + 1
end
end
end
end
EasyChat.LocalMessagePanel = panel
return "Local Message UI"

View File

@ -1,101 +0,0 @@
local DoLuaTab = function()
local luadev = requirex("luadev")
local luaTab = vgui.Create( "DPanel")
EasyChat.AddTab("LuaTab",luaTab)
luaTab.code = ""
local lastAction = {
script = "",
type = "",
time = "",
}
local RegisterAction = function(script,type)
lastAction = {
script = string.len(script) > 50 and string.sub(script,1,50).."..." or script,
type = type,
time = os.date("%H:%M:%S"),
}
end
luaTab.bar = vgui.Create("DMenuBar", luaTab)
local bar = luaTab.bar
bar:Dock( NODOCK )
bar:DockPadding( 5, 0, 0, 0 )
bar.Think = function( self )
self:SetSize(luaTab:GetWide(), 25 )
end
bar.Paint = function(self,w,h)
surface.SetDrawColor(EasyChat.TabColor)
surface.DrawRect(0,0,w,h)
surface.SetDrawColor(EasyChat.TabOutlineColor)
surface.DrawOutlinedRect(0,0,w,h)
end
bar.addButton = function(name, icon, cb, size, insert)
local b = bar:Add( "DButton" )
b:SetText( name )
b:SetIcon(icon)
b:Dock( LEFT )
b:SetSize(32+(size or 0), bar:GetTall())
b:SetTextInset( b.m_Image:GetWide() + (insert or 0), 0 )
b:SetPaintBackground( false )
b:SetTextColor(EasyChat.TextColor)
b.DoClick = function()
cb()
end
end
bar.addButton("Clients", "icon16/user.png", function()
luadev.RunOnClients(luaTab.code,LocalPlayer())
RegisterAction(luaTab.code,"clients")
end, 50, 60)
bar.addButton("Clientside", "icon16/cog_go.png", function()
luadev.RunOnSelf(luaTab.code,LocalPlayer())
RegisterAction(luaTab.code,"self")
end, 62, 50)
bar.addButton("Shared", "icon16/world.png", function()
luadev.RunOnShared(luaTab.code,LocalPlayer())
RegisterAction(luaTab.code,"shared")
end, 52, 40)
bar.addButton("Server", "icon16/server.png", function()
luadev.RunOnServer(luaTab.code,LocalPlayer())
RegisterAction(luaTab.code,"server")
end, 40, 20)
local html = vgui.Create( "DHTML" , luaTab )
html:SetPos(0,25)
html:AddFunction("gmodinterface", "OnReady", function( )
html:Call('SetContent("' .. string.JavascriptSafe(luaTab.code) .. '");')
end)
html:AddFunction("gmodinterface", "OnCode", function( code )
luaTab.code = code
end)
html.Think = function( self )
self:SetSize(luaTab:GetWide(),luaTab:GetTall()-50)
end
html:OpenURL("metastruct.github.io/lua_editor/")
local status = vgui.Create("DLabel",luaTab)
status:SetTextColor(EasyChat.TextColor)
status:Dock(BOTTOM)
status:SetSize(luaTab:GetWide(),25)
status.Paint = function(self,w,h)
surface.SetDrawColor(EasyChat.TabColor)
surface.DrawRect(0,0,w,h)
surface.SetDrawColor(EasyChat.TabOutlineColor)
surface.DrawOutlinedRect(0,0,w,h)
end
status.Think = function(self)
self:SetText(lastAction.script ~= "" and (((" "):rep(3)).."["..lastAction.time.."] Ran ("..lastAction.script..") on "..lastAction.type) or "")
end
end
if notagain and notagain.hasloaded then
DoLuaTab()
else
hook.Add("NotagainPostLoad","EasyChatModuleLuaTab",DoLuaTab)
end

View File

@ -9,3 +9,5 @@ hook.Add("OnPlayerChat","EasyChatModuleRPTAGS",function(ply,txt)
return true
end
end)
return "RP Commands"

View File

@ -0,0 +1,16 @@
local replaces = {
[".iunno"] = [[¯\_(ツ)_/¯]],
[".lenny"] = [[( ͡° ͜ʖ ͡° )]],
[".fliptable"] = [[(╯°□°)╯︵ ┻━┻]],
[".unflip "] = [[┬─┬ ( ゜-゜ノ)]],
}
hook.Add("OnChatTab","EasyChatModuleEmojisReplacement",function(text)
local args = string.Explode(" ",text)
if replaces[args[#args]] then
args[#args] = replaces[args[#args]]
end
return table.concat(args," ",1,#args)
end)
return "Tab Replacements"

View File

@ -7,7 +7,7 @@ if CLIENT then
local tentry = panel:Add("DTextEntry")
EasyChat.AddTab("PMs",panel)
plys:Dock(LEFT)
plys:DockMargin(5,5,15,5)
add:Dock(LEFT)
@ -57,7 +57,7 @@ if CLIENT then
end
if code == KEY_TAB then
local a = hook.Run("OnChatTab", self:GetText())
local a = hook.Run("OnChatTab", self:GetText())
self:SetText(a)
timer.Simple(0, function() self:RequestFocus() self:SetCaretPos(#self:GetText()) end)
return true
@ -89,35 +89,35 @@ if CLIENT then
local AppendPM = function(ply,msg)
local PM = GetPM(ply)
local isurl,_ = EasyChat.IsURL(msg)
PM.RichText:InsertColorChange(team.GetColor(ply:Team()))
PM.RichText:AppendText(ply:GetName())
PM.RichText:InsertColorChange(255,255,255,255)
PM.RichText:AppendText(":")
if isurl then -- CANCER V2
local poses = EasyChat.GetURLPoses(msg)
for k,pos in pairs(poses) do
local lspos,lepos = pos.Start,pos.End
PM.RichText:AppendText(string.sub(msg,k == 1 and 1 or pos[k - 1].End + 1,lspos - 1))
local insert = string.sub(msg,lspos,lepos)
local url,_ = string.gsub(insert,"^%s:","")
local _,www = EasyChat.IsURL(insert)
PM.RichText:InsertClickableTextStart(www and "http://"..url or url)
PM.RichText:AppendText(insert)
PM.RichText:InsertClickableTextEnd()
PM.RichText:AppendText(string.sub(msg,lepos + 1,pos[k + 1] and pos[k + 1].Start - 1 or nil))
end
else
PM.RichText:AppendText(msg)
end
PM.RichText:AppendText("\n")
--if EasyChat.TabControl:GetActiveTab() ==
--if EasyChat.TabControl:GetActiveTab() ==
end
end
@ -125,3 +125,5 @@ end
if SERVER then
end
return "Private Messages"

View File

@ -0,0 +1,59 @@
local netstring = "EASY_CHAT_SERVER_INPUT"
hook.Remove("Think","EasyChatModuleEPOE")
if CLIENT then
local panel = vgui.Create("DPanel")
local loaded = false
EasyChat.AddTab("Epoe",panel)
local commandentry = panel:Add("DTextEntry")
commandentry:Dock(BOTTOM)
commandentry.OnKeyCodeTyped = function( self, code )
if code == KEY_ENTER then
if string.Trim( self:GetText() ) ~= "" then
net.Start(netstring)
net.WriteString(string.sub(self:GetText(),1,200))
net.SendToServer()
self:SetText("")
end
end
end
EasyChat.SetFocusForOn("Epoe",commandentry)
local DoEpoeTab = function()
epoe.GUI.old_think = epoe.GUI.old_think or epoe.GUI.Think
epoe.GUI.Think = function(self)
epoe.GUI.old_think(self)
if not IsValid(panel) or not IsValid(commandentry) then return end
local x,y,w,h = panel:GetBounds()
self:SetPos(x,y)
self:SetSize(w,h-commandentry:GetTall())
end
end
hook.Add("Think","EasyChatModuleEPOE",function(self)
if epoe and epoe.GUI and not loaded then
DoEpoeTab()
loaded = true
end
if loaded and epoe and not epoe.GUI then
loaded = false
end
end)
end
if SERVER then
util.AddNetworkString(netstring)
net.Receive(netstring,function(len,ply)
if ply:IsAdmin() then
local cmd = net.ReadString()
game.ConsoleCommand(cmd.."\n")
end
end)
end
return "EPOE"

View File

@ -0,0 +1,43 @@
local tag = "EasyChatModuleJoinLeave"
if SERVER then
util.AddNetworkString(tag)
gameevent.Listen("player_connect")
gameevent.Listen("player_disconnect")
hook.Add("player_connect",tag,function(data)
net.Start(tag)
net.WriteTable(data)
net.Broadcast()
end)
hook.Add("player_disconnect",tag,function(data)
net.Start(tag)
net.WriteTable(data)
net.Broadcast()
end)
end
if CLIENT then
hook.Add("ChatText",tag,function(_,_,_,mode)
if mode == "joinleave" then
return true
end
end)
net.Receive(tag,function()
local info = net.ReadTable()
if not info.reason then
chat.AddText(Color(92,184,92), "", Color(200,200,200),info.name,Color(175,175,175)," (" .. info.networkid .. ") is ", Color(92,184,92), "joining")
else
chat.AddText(Color(209,62,57), "", Color(200,200,200),info.name,Color(175,175,175)," (" .. info.networkid .. ") has ", Color(209,62,57), "left",Color(175,175,175)," ("..info.reason..")")
end
end)
end
return "JoinLeave Notifications"

View File

@ -0,0 +1,189 @@
local netluaclients = "EASY_CHAT_MODULE_LUA_CLIENTS"
local netluasv = "EASY_CHAT_MODULE_LUA_SV"
local lua = {}
if CLIENT then
lua.RunOnClients = function(code,ply)
net.Start(netluasv)
net.WriteString(code)
net.WriteString("clients")
net.SendToServer()
end
lua.RunOnSelf = function(code,ply)
if LocalPlayer():IsSuperAdmin() and GetConVar("sv_allowcslua"):GetBool() then
CompileString(code,LocalPlayer():GetName())()
end
end
lua.RunOnShared = function(code,ply)
net.Start(netluasv)
net.WriteString(code)
net.WriteString("shared")
net.SendToServer()
end
lua.RunOnServer = function(code,ply)
net.Start(netluasv)
net.WriteString(code)
net.WriteString("server")
net.SendToServer()
end
net.Receive(netluaclients,function(len)
local code = net.ReadString()
local ply = net.ReadEntity()
if not IsValid(ply) then return end
CompileString(code,ply:GetName())()
end)
end
if SERVER then
util.AddNetworkString(netluaclients)
util.AddNetworkString(netluasv)
net.Receive(netluasv,function(len,ply)
if not IsValid(ply) then return end
local code = net.ReadString()
local mode = net.ReadString()
if ply:IsSuperAdmin() then
if string.match(mode,"server") then
CompileString(code,ply:GetName())()
elseif string.match(mode,"clients") then
net.Start(netluaclients)
net.WriteString(code)
net.WriteEntity(ply)
net.Broadcast()
elseif string.match(mode,"shared") then
CompileString(code,ply:GetName())()
net.Start(netluaclients)
net.WriteString(code)
net.WriteEntity(ply)
net.Broadcast()
end
end
end)
end
if CLIENT then
CreateConVar("easychat_luatab","1",FCVAR_ARCHIVE,"Display luatab or not")
cvars.AddChangeCallback("easychat_luatab",function(name,old,new)
LocalPlayer():ConCommand("easychat_reload")
end)
if not GetConVar("easychat_luatab"):GetBool() then return "LuaTab" end
local luaTab = vgui.Create( "DPanel")
EasyChat.AddTab("LuaTab",luaTab)
luaTab.code = ""
local lastAction = {
script = "",
type = "",
time = "",
}
local RegisterAction = function(script,type)
lastAction = {
script = string.Explode(" ",script)[1].."...",
type = type,
time = os.date("%H:%M:%S"),
}
end
luaTab.bar = vgui.Create("DMenuBar", luaTab)
local bar = luaTab.bar
bar:Dock( NODOCK )
bar:DockPadding( 5, 0, 0, 0 )
bar.Think = function( self )
self:SetSize(luaTab:GetWide(), 25 )
end
if not EasyChat.UseDermaSkin then
bar.Paint = function(self,w,h)
surface.SetDrawColor(EasyChat.TabColor)
surface.DrawRect(0,0,w,h)
surface.SetDrawColor(EasyChat.TabOutlineColor)
surface.DrawOutlinedRect(0,0,w,h)
end
end
bar.addButton = function(name, icon, cb, size, insert)
local b = bar:Add( "DButton" )
b:SetText( name )
b:SetIcon(icon)
b:Dock( LEFT )
b:SetSize(32+(size or 0), bar:GetTall())
b:SetTextInset( b.m_Image:GetWide() + (insert or 0), 0 )
b:SetPaintBackground( false )
b:SetTextColor(EasyChat.TextColor)
b.DoClick = function()
cb()
end
end
bar.addButton("Clients", "icon16/user.png", function()
lua.RunOnClients(luaTab.code,LocalPlayer())
RegisterAction(luaTab.code,"clients")
end, 50, 60)
bar.addButton("Clientside", "icon16/cog_go.png", function()
lua.RunOnSelf(luaTab.code,LocalPlayer())
RegisterAction(luaTab.code,"self")
end, 62, 50)
bar.addButton("Shared", "icon16/world.png", function()
lua.RunOnShared(luaTab.code,LocalPlayer())
RegisterAction(luaTab.code,"shared")
end, 52, 40)
bar.addButton("Server", "icon16/server.png", function()
lua.RunOnServer(luaTab.code,LocalPlayer())
RegisterAction(luaTab.code,"server")
end, 40, 20)
local html = vgui.Create( "DHTML" , luaTab )
html:SetPos(0,25)
html:AddFunction("gmodinterface", "OnReady", function( )
html:Call('SetContent("' .. string.JavascriptSafe(luaTab.code) .. '");')
end)
html:AddFunction("gmodinterface", "OnCode", function( code )
luaTab.code = code
end)
html.Think = function( self )
self:SetSize(luaTab:GetWide(),luaTab:GetTall()-50)
end
html:OpenURL("metastruct.github.io/lua_editor/")
local status = vgui.Create("DLabel",luaTab)
status:SetTextColor(EasyChat.TextColor)
status:Dock(BOTTOM)
status:SetSize(luaTab:GetWide(),25)
if not EasyChat.UseDermaSkin then
status.Paint = function(self,w,h)
surface.SetDrawColor(EasyChat.TabColor)
surface.DrawRect(0,0,w,h)
surface.SetDrawColor(EasyChat.TabOutlineColor)
surface.DrawOutlinedRect(0,0,w,h)
end
end
status.Think = function(self)
self:SetText(lastAction.script ~= "" and (((" "):rep(3)).."["..lastAction.time.."] Ran "..lastAction.script.." on "..lastAction.type) or "")
end
EasyChat.SetFocusForOn("LuaTab",html)
if notagain and notagain.hasloaded then
lua = notagain.loaded_libraries.luadev
else
if _G.luadev then
lua = _G.luadev
else
hook.Add("NotagainPostLoad","EasyChatModuleLuaTab",function()
lua = notagain.loaded_libraries.luadev
end)
end
end
end
return "LuaTab"

View File

@ -48,4 +48,6 @@ if SERVER then
hook.Add("DiscordRelayMessage","EasyChatModuleMention",networkdiscordmention)
end
end
end
return "Mentions"

View File

@ -1,8 +1,9 @@
hook.Add("MediaPlayerAddListener", "mediaplayer_listener_chatprint", function(mp, ply)
for _, v in pairs(mp:GetListeners()) do
if ply ~= v and v:IsValid() then
v:ChatPrint(ply:Nick() .. " has subscribed to MediaPlayer[" ..mp.Entity:EntIndex().."]")
ply:ChatPrint(v:Nick() .. " is subscribed to MediaPlayer[" ..mp.Entity:EntIndex().."]")
local owner = mp.Entity:CPPIGetOwner()
v:ChatPrint(ply:Nick() .. " has subscribed to " ..owner:Nick().."'s MediaPlayer")
ply:ChatPrint(v:Nick() .. " is subscribed to " ..owner:Nick().."'s MediaPlayer")
end
end
end)
@ -10,7 +11,10 @@ end)
hook.Add("MediaPlayerRemoveListener", "mediaplayer_listener_chatprint", function(mp, ply)
for _, v in pairs(mp:GetListeners()) do
if v:IsValid() then
v:ChatPrint(ply:Nick() .. " has unsubscribed from MediaPlayer[" ..mp.Entity:EntIndex().."]")
local owner = mp.Entity:CPPIGetOwner()
v:ChatPrint(ply:Nick() .. " has unsubscribed from " ..owner:Nick().."'s MediaPlayer")
end
end
end)
return "MediaPlayer Notifications"