Custom chatbox problem

I have a custom chatbox and I’m running fretta, but if a player votes to change the gamemode, the message doesn’t appear in the chat, instead you can only see it from console. If someone could help me in any way, it’ll be greatly appreciated.

Check message types and stuff, it calls on messages like that i think

If that doesn’t work, override chat.AddText

How do I override it?

[lua]function chat.AddText( … )
PrintTable( {…} ) – Override the chat.AddText and do nothing else but printing the arguments
end;
[/lua]

Still doesn’t work, here’s the chat:
(I didn’t know where to put that)
[lua]
function CursorPos(x,y,w,h)
local mx,my = gui.MousePos()

if (mx>x)and(mx<x+w)and(my>y)and(my<y+h) then return true end
return false

end

surface.CreateFont(“Trebuchet18”, 16, 1000, true, false, “Text”)

chatshow = false
tchatshow = false

local writetext = “”
local msgtext = “”
local linestoshow = 13
local chathistory = {}

local stxt = {}; function CPrefix(index, ptxt) stxt[index] = ptxt; end

function SendMessage(pl, msg, typ, color)
typ = tonumber(type) or 0
if ValidEntity(pl) then
local chatInfo = {
pl = pl,
name = pl:GetName(),
msgtextcolor = color or Color(255, 255, 255, 255),
teamcolor = team.GetColor(pl:Team()),
msg = msg,
typ = type,
time = RealTime()+15,
tag = string.sub(pl:GetNWString(“currtag”), 1, -5)
};
if type == 2 then
-UNNEEDED SHIT-
draw.SimpleText(v.msg, “Text”, x2+1, (y-*15)+1, Color(0, 0, 0, 255))
draw.SimpleText(v.msg, “Text”, x2, y-
*15, v.msgtextcolor)
else
draw.SimpleText(v.msg, “Text”, x+1, (y-*15)+1, Color(0, 0, 0, 255))
draw.SimpleText(v.msg, “Text”, x, y-
*15, v.msgtextcolor)
end
end
end

if chatshow then
surface.SetFont(“Text”)
local ptxt = “Chat”

    local stext = ptxt.."> "..msgtext
    local w, h = surface.GetTextSize(stext)
        
    draw.RoundedBox(0, x-6, y+3, w+16, h+5, Color(25, 25, 25, 255))
    draw.RoundedBox(2, x-5, y+4, w+14, h+3, Color(255, 255, 255, 255))

    surface.SetTextColor(25, 25, 25, 255)
    surface.SetTextPos(x+2, y+5)
    surface.DrawText(stext)
end

end
hook.Add(“HUDPaint”, “DrawChat”, ChatPaint)

hook.Add(“ChatText”, “ChatMessages”, function(plindex, plname, text, typ)
if typ == “none” then
SendMessage(nil, text, nil, Color(0, 154, 205, 255))
elseif typ == “joinleave” then
SendMessage(nil, text, nil, Color(102, 205, 170, 255))
end
end)

hook.Add(“StartChat”, “StartChat”, function() chatshow = true; return true; end)
hook.Add(“FinishChat”, “FinishChat”, function() chatshow = false; writetext = “”; msgtext = “”; end)
hook.Add(“ChatTextChanged”, “TextChanged”, function(text) writetext = text; msgtext = text; end)
hook.Add(“PlayerBindPress”, “TeamChat”, function(pl, bind) if string.find(bind, “messagemode2”) then tchatshow = true; end end) [/lua]

Check if theres any more types than none and joinleave

Didn’t find any.

Fretta votes use chat.AddText. Overwrite as said above. There is no other way.

Okay, but how do I overwrite. When I add those lines in the code, I still can’t see the player votechange messages.

PrintTable( {…} ) – Override the chat.AddText and do nothing else but printing the arguments

Do you understand what that does? because it isnt supposed to print to your chat, the example you were given just prints it to the console

Well, point me to the right direction, will you?

Why don’t you wrap the text instead of widening the chatbox to fit said text?

The thing is, I have no idea how to. Why don’t you post the code?

[lua]
function chat.AddText( args ) – Were rewriting how it is displayed.
SendMessage(nil, args, 2, Color(102, 205, 170, 255))
end

function CursorPos(x,y,w,h)
local mx,my = gui.MousePos()

if (mx>x)and(mx<x+w)and(my>y)and(my<y+h) then return true end
return false

end

surface.CreateFont(“Trebuchet18”, 16, 1000, true, false, “Text”)

chatshow = false
tchatshow = false

local writetext = “”
local msgtext = “”
local linestoshow = 13
local chathistory = {}

local stxt = {}; function CPrefix(index, ptxt) stxt[index] = ptxt; end
function SendMessage(pl, msg, typ, color)
typ = tonumber(type) or 0
local chatInfo = {
pl = pl,
name = pl:GetName(),
msgtextcolor = color or Color(255, 255, 255, 255),
teamcolor = team.GetColor(pl:Team()),
msg = msg,
typ = type,
time = RealTime()+15,
tag = string.sub(pl:GetNWString(“currtag”), 1, -5)
};
if type == 2 then – chat.AddText and Console
draw.SimpleText(v.msg, “Text”, x2+1, (y-*15)+1, Color(0, 0, 0, 255))
draw.SimpleText(v.msg, “Text”, x2, y-
*15, v.msgtextcolor)
else
draw.SimpleText(v.msg, “Text”, x+1, (y-*15)+1, Color(0, 0, 0, 255))
draw.SimpleText(v.msg, “Text”, x, y-
*15, v.msgtextcolor)
end
end

if chatshow then
surface.SetFont(“Text”)
local ptxt = “Chat”
local stext = ptxt…"> "…msgtext
local w, h = surface.GetTextSize(stext)
draw.RoundedBox(0, x-6, y+3, w+16, h+5, Color(25, 25, 25, 255))
draw.RoundedBox(2, x-5, y+4, w+14, h+3, Color(255, 255, 255, 255))
surface.SetTextColor(25, 25, 25, 255)
surface.SetTextPos(x+2, y+5)
surface.DrawText(stext)
end
hook.Add(“HUDPaint”, “DrawChat”, ChatPaint)

hook.Add(“ChatText”, “ChatMessages”, function(plindex, plname, text, typ)
if typ == “none” then
SendMessage(nil, text, nil, Color(0, 154, 205, 255))
elseif typ == “joinleave” then
SendMessage(nil, text, nil, Color(102, 205, 170, 255))
end
end)

hook.Add(“StartChat”, “StartChat”, function() chatshow = true; return true; end)
hook.Add(“FinishChat”, “FinishChat”, function() chatshow = false; writetext = “”; msgtext = “”; end)
hook.Add(“ChatTextChanged”, “TextChanged”, function(text) writetext = text; msgtext = text; end)
hook.Add(“PlayerBindPress”, “TeamChat”, function(pl, bind) if string.find(bind, “messagemode2”) then tchatshow = true; end end)
[/lua]

Not tested by should work. Code look very familiar.

I already got helped out, thanks anyways.