• Admin Tag Message
    2 replies, posted
Init.lua [CODE]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, ")"})[/CODE] cl_init [CODE]net.Receive("AdminMsg", function() local msg = net.ReadTable() chat.AddText(unpack(msg)) end)[/CODE] Result when called [IMG]http://i.imgur.com/2ZofTtT.png[/IMG] 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: [code] for k, v in ipairs( msg ) do table.insert( tag, v ) end [/code]
[QUOTE=Willox;46496187]You're inserting a table in to your table, rather than its values. One way to solve it: [code] for k, v in ipairs( msg ) do table.insert( tag, v ) end [/code][/QUOTE] Cheers mate, still getting used to this table stuff.
Sorry, you need to Log In to post a reply to this thread.