Hey guys, so I am making a chat tags addon for my TTT server, but I’m having this error when I type in the chat.
http://puu.sh/wNJ7e/c0abf14d28.jpg
I’m assuming this has to do with the sandbox gamemode but I don’t know how to override the default chat. Any help would be appreciated.
Code:
-- [[ Custom Tags ]] ----------------------------
-- [[ Created by: Dogger ]] ---------------------
-- [[ Designed for Boujee Gamers TTT Server ]] --
-- Clientside File
local tag = {}
local ply = LocalPlayer()
local color = {}
color.pl = Color(0, 255, 0, 255)
color.tag = Color(255, 0, 0, 255)
function OpenMenu()
local frame = vgui.Create("DFrame")
frame.width = 390
frame.height = 390
frame:SetSize(frame.width, frame.height)
frame:SetPos(400, 500)
frame:MakePopup()
frame:SetTitle("Boujee TTT Custom Tags")
frame:AlignLeft(20)
-- Set Tag button
local button1 = vgui.Create("DButton", frame)
button1.width = 110
button1.height = 25
button1.x = 25
button1.y = 50
button1:SetSize(button1.width, button1.height)
button1:SetPos(button1.x, button1.y)
button1:SetText("Set Tag")
--Change Tag Color button
local button2 = vgui.Create("DButton", frame)
button2.width = 110
button2.height = 25
button2.x = 25
button2.y = 130
button2:SetSize(button2.width, button2.height)
button2:SetPos(button2.x, button2.y)
button2:SetText("Set Tag Color")
--Change Name Color button
local button3 = vgui.Create("DButton", frame)
button3.width = 110
button3.height = 25
button3.x = 25
button3.y = 250
button3:SetSize(button3.width, button3.height)
button3:SetPos(button3.x, button3.y)
button3:SetText("Set Name Color")
--Tag text entry
local tagEntry = vgui.Create("DTextEntry", frame)
tagEntry.x = button1.x + 134
tagEntry.y = button1.y + 2
tagEntry:SetPos(tagEntry.x, tagEntry.y)
tagEntry:SetSize(180, 20)
tagEntry:SetUpdateOnType(true)
tagEntry:SetText("Enter Custom Tag")
tagEntry.OnValueChange = function(self)
tagEntry.value = self:GetValue()
end
-- Tag Color Mixer
local colorPicker1 = vgui.Create("DColorMixer", frame)
colorPicker1.x = button2.x + 135
colorPicker1.y = button2.y - 30
colorPicker1:SetPos(colorPicker1.x, colorPicker1.y)
colorPicker1:SetPalette(false)
colorPicker1:SetAlphaBar(false)
colorPicker1:SetColor(Color(30, 100, 160) )
colorPicker1:SetSize(180, 100)
-- Name Color Mixer
local colorPicker2 = vgui.Create("DColorMixer", frame)
colorPicker2.x = button3.x + 135
colorPicker2.y = button3.y - 30
colorPicker2:SetPos(colorPicker2.x, colorPicker2.y)
colorPicker2:SetPalette(false)
colorPicker2:SetAlphaBar(false)
colorPicker2:SetColor(Color(30, 100, 160) )
colorPicker2:SetSize(180, 100)
-- Set tag button is pressed
button1.DoClick = function()
tag.CustomTag = tagEntry.value
tag.Enabled = true
chat.AddText(Color(255,0,0,255), "[Tags] ", color_white, "You have set your tag to ", color.tag, tag.CustomTag )
end
-- Tag Color button pressed
button2.DoClick = function()
if tag.Enabled == true then
tag.CustomColor = colorPicker1:GetColor()
chat.AddText(Color(255,0,0,255), "[Tags] ", color_white, "Tag color changed: ", tag.CustomColor, tag.CustomTag, color_white, "." )
else
chat.AddText(Color(255,0,0,255), "[Tags] Error: ", color_white, "You must have a tag enabled to set it's color!")
end
end
-- Name Color button pressed
button3.DoClick = function()
tag.CustomNameColor = colorPicker2:GetColor()
chat.AddText(Color(255,0,0,255), "[Tags] ", color_white, "Name color changed: ", tag.CustomNameColor, ply:Nick(), color_white, "." )
end
end
// - Open the menu when player types command - //
hook.Add("OnPlayerChat", "PlayerChat", function( ply, text )
if text == "!tags" then OpenMenu() end
if tag.Enabled == true then
chat.AddText(tag.CustomColor, "[", tag.CustomTag, "]", " ", tag.CustomNameColor, ply:Nick(), ": ", color_white, text)
end
end )
This is one of the first things I have created in lua, so I would also appreciate any tips on how I could improve my code!