ULX

Author Topic: ULX Chat Tags  (Read 4683 times)

0 Members and 1 Guest are viewing this topic.

Offline crazymankills

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
ULX Chat Tags
« 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.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX Chat Tags
« Reply #1 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
ULib has one too, but I forget if it's smarter in any way (re:might return inheritance, etc)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline crazymankills

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: ULX Chat Tags
« Reply #2 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 ?

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: ULX Chat Tags
« Reply #3 on: March 15, 2014, 02:25:53 PM »
Name it tags.lua. Put it in garrysmod/lua/autorun directory.

Mr582

  • Guest
Re: ULX Chat Tags
« Reply #4 on: March 15, 2014, 02:29:09 PM »
I did a little modification to this thread. 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.