Admin Tag Message

Init.lua


function AdminMsg( msg )
	local tag = {}
	table.insert(tag, color_white)
	table.insert(tag, "[")
	table.insert(tag, Color(255,0,0))
	table.insert(tag, "Admin")
	table.insert(tag, color_white)
	table.insert(tag, "] ")
	table.insert(tag, 7, msg)
	net.Start("AdminMsg")
	net.WriteTable(tag)
	net.Broadcast()
end

AdminMsg({Color(50,150,255), ply:Nick(), color_white, " kicked ", Color(50,150,255), target:Nick(), color_white, " (", Color(50,150,255), tostring(text[3]), color_white, ")"})

cl_init


net.Receive("AdminMsg", function()
  local msg = net.ReadTable()
  chat.AddText(unpack(msg))
end)

Result when called

Whats wrong with my code that doesn’t make the ‘msg’ table print after the tag?

You’re inserting a table in to your table, rather than its values.

One way to solve it:



for k, v in ipairs( msg ) do
    table.insert( tag, v )
end


Cheers mate, still getting used to this table stuff.