Tags

I’m writing a script that gives tags to players, ex: User moderator admin, then the name and the message.

This is what I have:
if (SERVER) then
AddCSLuaFile(“autorun/tags.lua”)
end

if (CLIENT) then
function Insert( pl, msg )
local tab = {}
if pl:IsUserGroup(“headmanagement”) then
table.insert( tab, Color( 255, 0, 0, 255 ) )
table.insert( tab, "[Head Management] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“superadmin”) then
table.insert( tab, Color( 0, 255, 0, 255 ) )
table.insert( tab, "[Head Management] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“admin”) then
table.insert( tab, Color( 0, 255, 0, 255 ) )
table.insert( tab, "[Management] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“leadmanagement”) then
table.insert( tab, Color( 0, 255, 0, 255 ) )
table.insert( tab, "[Lead Management] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“management”) then
table.insert( tab, Color( 0, 35, 175, 255 ) )
table.insert( tab, "[Management] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“leadmoderator”) then
table.insert( tab, Color( 0, 74, 175, 255 ) )
table.insert( tab, "[Lead Moderator] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“moderator”) then
table.insert( tab, Color( 0, 185, 35, 255 ) )
table.insert( tab, "[Moderator] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“premium”) then
table.insert( tab, Color( 255, 0, 175, 255 ) )
table.insert( tab, "[Premium] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“trusted”) then
table.insert( tab, Color( 255, 0, 175, 255 ) )
table.insert( tab, "[Trusted] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“supporter”) then
table.insert( tab, Color( 255, 0, 175, 255 ) )
table.insert( tab, "[Supporter] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
else
table.insert( tab, Color( 86, 185, 80, 255 ) )
table.insert( tab, "[User] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
end
chat.AddText( unpack(tab) )
return true
end
end
hook.Add(“OnPlayerChat”, “InsertTags”, Insert)

This works to the extent that it was say “Management” but completely gets rid of the name.
How would I fix this?

Use:

But with square brackets instead.

That is a crazy inefficient way to make tables sir.

How else would I do it?

Any way but that. Also, please put damn lua tags around your code; would be an added bonus if you pushed some tabs in there so we could actually read it properly.

I’m sorry =( How do I copy it so it is spaced correctly? Like on notepad ++?

[editline]3rd January 2013[/editline]

if (SERVER) then
AddCSLuaFile(“autorun/tags.lua”)
end

if (CLIENT) then
function Insert( pl, msg )
local tab = {}
if pl:IsUserGroup(“headmanagement”) then
table.insert( tab, Color( 255, 0, 0, 255 ) )
table.insert( tab, "[Head Management] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“superadmin”) then
table.insert( tab, Color( 0, 255, 0, 255 ) )
table.insert( tab, "[Head Management] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“admin”) then
table.insert( tab, Color( 0, 255, 0, 255 ) )
table.insert( tab, "[Administrator] " … ply )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“leadmanagement”) then
table.insert( tab, Color( 0, 255, 0, 255 ) )
table.insert( tab, "[Lead Management] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“management”) then
table.insert( tab, Color( 0, 35, 175, 255 ) )
table.insert( tab, "[Management] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, ply:Nick( ply ) )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“leadmoderator”) then
table.insert( tab, Color( 0, 74, 175, 255 ) )
table.insert( tab, "[Lead Moderator] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“moderator”) then
table.insert( tab, Color( 0, 185, 35, 255 ) )
table.insert( tab, "[Moderator] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“premium”) then
table.insert( tab, Color( 255, 0, 175, 255 ) )
table.insert( tab, "[Premium] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“trusted”) then
table.insert( tab, Color( 255, 0, 175, 255 ) )
table.insert( tab, "[Trusted] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup(“supporter”) then
table.insert( tab, Color( 255, 0, 175, 255 ) )
table.insert( tab, "[Supporter] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
else
table.insert( tab, Color( 86, 185, 80, 255 ) )
table.insert( tab, "[User] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl )
table.insert( tab, ": " )
table.insert( tab, msg )
end
chat.AddText( unpack(tab) )
return true
end
end
hook.Add(“OnPlayerChat”, “InsertTags”, Insert)

[editline]3rd January 2013[/editline]

I can’t get it to look proper -_-

try

[noparse]
[lua]
-code-
[/lua]
[/noparse]