Ulysses

General => Developers Corner => Topic started by: crazymankills on March 15, 2014, 12:37:26 PM

Title: ULX Chat Tags
Post by: crazymankills on March 15, 2014, 12:37:26 PM
So I am trying to make chat tags that pull from my ulx ranks but I don't even know were to start and what to do I tried and just get confused, I would appreciate if someone could help me / point me in the right direction.
Title: Re: ULX Chat Tags
Post by: JamminR on March 15, 2014, 01:12:11 PM
Search the "developers corner' for the word tag(or tags).
Plenty of other code discussions to get you on your way.
There's even a chat tag addon in the releases section, but to my memory, it doesn't pull ulx groups.

You'll likely want to use Gmod's GetUserGroup (http://wiki.garrysmod.com/page/Player/GetUserGroup)
ULib has one too, but I forget if it's smarter in any way (re:might return inheritance, etc)
Title: Re: ULX Chat Tags
Post by: crazymankills on March 15, 2014, 02:11:41 PM
Code: [Select]
if (SERVER) then
AddCSLuaFile("autorun/tags.lua")
end

if (CLIENT) then
function Insert( pl, msg )
local tab = {}
if pl:IsUserGroup("Owner") then
table.insert( tab, Color( 255, 0, 0, 255 ) )
table.insert( tab, "[Owner] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl:Nick() )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup("Co Owner") then
table.insert( tab, Color( 255, 0, 0, 255 ) )
table.insert( tab, "[Co Owner] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl:Nick() )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup("Developer") then
table.insert( tab, Color( 255, 0, 0, 255 ) )
table.insert( tab, "[Dev] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl:Nick() )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup("SuperAdmin") then
table.insert( tab, Color( 33, 110, 252, 255 ) )
table.insert( tab, "[Super Admin] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl:Nick() )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup("Admin") then
table.insert( tab, Color( 33, 110, 252, 255 ) )
table.insert( tab, "[Admin] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl:Nick() )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup("Mod") then
table.insert( tab, Color( 245, 226, 20, 255 ) )
table.insert( tab, "[Mod] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl:Nick() )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup("Member") then
table.insert( tab, Color( 194, 19, 153, 255 ) )
table.insert( tab, "[Member] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl:Nick() )
table.insert( tab, ": " )
table.insert( tab, msg )
elseif pl:IsUserGroup("Vip") then
table.insert( tab, Color( 86, 185, 80, 255 ) )
table.insert( tab, "[Vip] " )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, pl:Nick() )
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:Nick() )
table.insert( tab, ": " )                     
table.insert( tab, msg )
end
chat.AddText( unpack(tab) )
return true
end
hook.Add("OnPlayerChat", "InsertTags", Insert)
end
I got this but what do I name it ???? Chat Tags.lua and where do I put it ?
Title: Re: ULX Chat Tags
Post by: MrPresident on March 15, 2014, 02:25:53 PM
Name it tags.lua. Put it in garrysmod/lua/autorun directory.
Title: Re: ULX Chat Tags
Post by: Mr582 on March 15, 2014, 02:29:09 PM
I did a little modification to this thread (http://forums.ulyssesmod.net/index.php/topic,6196). Full credit to them because my modification was pretty small. I will put a download anyway to my version bellow anyway, but give them credit.