Ulysses
General => Developers Corner => Topic started by: Bite That Apple on February 03, 2013, 08:08:03 PM
-
Hi, I'm somewhat fairly new to lua, so sorry if what I'm asking makes me sound dumb, and or doesn't make sense..
local Tags =
{
--Group --Tag --Color
{"admin", "[ADMIN] ", Color(0, 0, 255, 255) },
{"superadmin", "[SUPERADMIN] ", Color(255, 0, 0, 255) },
{"owner", "[", Color(255, 255, 255, 255), "Owner", "] ", Color(255, 255, 255, 255) }
}
hook.Add("OnPlayerChat", "Tags", function(ply, strText)
for k,v in pairs(Tags) do
if ply:IsUserGroup(v[1]) then
local nickteamcolor = team.GetColor(ply:Team())
local nickteam = team.GetName(ply:Team())
chat.AddText(v[3], v[2], nickteamcolor, nickteam, v[6], v[5], nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), strText)
return true
end
end
end )
You can assume what this going to do, but what to make it basically fully automatic so people don't have to add things to the {table} so it works properly, Anyways. I wanted to know the (or if one does exist) or a way so I can get this here -> ply:IsUserGroup(v[1]) to grab all ulib groups?
Any suggestions, help, tutorial, and or wiki would be much appreciated.
** also, sorry if this is in the incorrect section, if so please just move it :)**
-
The Ulib groups table is stored in ucl.groups (or, ULib.ucl.groups)
And please, though our forum 'allows' it, please, please, please shrink your signature image. :)
-
I've changed my signature to something about 10x smaller now, I hope it's okay.
Anyways, thank you I'm going to mess around now see if I can get it to work and than get back to this if it worked or not. :)
-
You'll need to parse the table of course. :) for pairs is your friend.
I'll leave that to you to figure out.
As for the signature, my easily distracted vision impaired eyes thank you!
-
Didn't seem to understand what you all meant, but it is 4:19AM, so I shall go to bed and hopefully understand a bit more. I do thank you for your reply.
-
You don't need to parse the ulib groups to do this. ULib automatically assigns groups to teams (or that might be ULX) either way, just try this...
function ChatTags(ply, strText)
chat.AddText(Color(0,0,0,255), "[", team.GetName(ply:Team()), "]", team.GetColor(ply:Team()), ply:Nick(), Color(255,255,255,255), ": ", strText)
return true
end
hook.Add("OnPlayerChat", "Tags", ChatTags)
my only concern is that since you are intercepting chat and returning another value with true will this not break all other chat hooks?
nevermind. This is the client version not the serverside version. The above code should work fine for what you need.
-
Thank you Mr. President.
Also, thank you as well JamminR. :)
Karma for both of you.