Author Topic: Chat prefixes/tags/titles/names  (Read 20396 times)

0 Members and 1 Guest are viewing this topic.

Offline sme4gle

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Chat prefixes/tags/titles/names
« on: March 21, 2012, 04:55:50 AM »
Hello, ive been searching AGES for a plugin or code to make something like this for the chat:

[Admin] sme4gle: Hello you!
[Trusted] Shadow: Hi there Sme4gle :D
But none of em seem to be working how i want ... ive tried like 4-5 different codes half of em doesnt work or is for evolvemod

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Chat prefixes/tags/titles/names
« Reply #1 on: March 21, 2012, 01:58:57 PM »
Sme4gle, due to the current ways chat hooks can be so easily broken if not done right, Team Ulysses will never support it within ULX.
Megiddo says as much in this thread, which also has, aptly stated, unsupported, untested, code by another community (and silent partner) Team Ulysses member.
Searching from the forum front page found me this.
http://forums.ulyssesmod.net/index.php/topic,5391.0.html

That's not to say Garry may not somehow change things in the future which make it not so easy to break, but, currently, no, not now.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline sme4gle

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Chat prefixes/tags/titles/names
« Reply #2 on: March 22, 2012, 01:42:54 AM »
ive tried that one before, but i cant get it working :/

Code: [Select]
local function lOnPlayerChat( ply, strText, bTeamOnly, bPlayerIsDead, bPlayerIsOwner, bPlayerIsCoowner, bPlayerIsSuperadmin, bPlayerIsAdmin, bPlayerIsOperator, bPlayerIsRespected, bPlayerIsGuest )
 
    local tab = {}

    local lTeam = 0
    if( IsValid( ply ) ) then
        lTeam = ply:Team()
    end

    table.insert( tab, Color( team.GetColor( lTeam ) ) )
    table.insert( tab, "[" .. team.GetName( lTeam ) .. "] " )
 
    if ( bPlayerIsOwner ) then
        table.insert( tab, Color( 255, 255, 255 ) )
        table.insert( tab, "[Owner] " )
    end

    if ( bPlayerIsCoowner ) then
        table.insert( tab, Color( 255, 255, 255 ) )
        table.insert( tab, "[Co-Owner] " )
    end

    if ( bPlayerIsSuperadmin ) then
        table.insert( tab, Color( 255, 255, 255 ) )
        table.insert( tab, "[Super-Admin] " )
    end
 
    if ( bPlayerIsAdmin ) then
        table.insert( tab, Color( 255, 255, 255 ) )
        table.insert( tab, "[Admin] " )
    end

    if ( bPlayerIsOperator ) then
        table.insert( tab, Color( 255, 255, 255 ) )
        table.insert( tab, "[Operator] " )
    end

    if ( bPlayerIsRespected ) then
        table.insert( tab, Color( 255, 255, 255 ) )
        table.insert( tab, "[Respected] " )
    end
   
    if (bPlayerIsGuest ) then
        table.insert( tab, Color( 255, 255, 255 ) )
        table.insert( tab, "[Guest] " )


 
    if ( IsValid( ply ) ) then
        table.insert( tab, ply:GetName() )
    else
        table.insert( tab, "Console" )
    end
 
    table.insert( tab, Color( 255, 255, 255 ) )
    table.insert( tab, ": "..strText )

    chat.AddText( unpack(tab) )
 
    return true
end

hook.Add( "OnPlayerChat", "PlayerChatTeamPrefix", lOnPlayerChat )
I'm not that good in lua but i thought this was kind of correct isnt it?

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Chat prefixes/tags/titles/names
« Reply #3 on: March 23, 2012, 07:05:48 PM »
Elaborate on "can't get it working". No change in behavior whatsoever? Are you sure you installed it correctly?
Experiencing God's grace one day at a time.

Offline Dimstar

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
Re: Chat prefixes/tags/titles/names
« Reply #4 on: August 29, 2013, 05:55:15 AM »
I found one that works for my server... here:
Code: [Select]
CreateClientConVar("chat_tags_color_r", 255, true, false)
CreateClientConVar("chat_tags_color_g", 255, true, false)
CreateClientConVar("chat_tags_color_b", 255, true, false)
CreateClientConVar("chat_tags_color_a", 255, true, false)

local Tags =
{
--Group    --Tag     --Color
{"user", "[User] ", Color(212, 67, 255, 255) },
{"admin", "[ADMIN] ", Color(0, 0, 255, 255) },
{"superadmin", "[SUPERADMIN] ", Color(255, 0, 0, 255) },
{"owner", "[OWNER] ", Color(0, 255, 0, 255) }
}

hook.Add("OnPlayerChat", "Tags", function(ply, strText, bTeamOnly)
if IsValid(ply) and ply:IsPlayer() then
for k,v in pairs(Tags) do
if ply:IsUserGroup(v[1]) then
local R = GetConVarNumber("chat_tags_color_r")
local G = GetConVarNumber("chat_tags_color_g")
local B = GetConVarNumber("chat_tags_color_b")
local A = GetConVarNumber("chat_tags_color_a")
local nickteam = team.GetColor(ply:Team())
if !bTeamOnly then
chat.AddText(v[3], v[2], nickteam, ply:Nick(), color_white, ": ", Color(R, G, B, A), strText)
return true
else
chat.AddText(v[3], v[2], nickteam, "(TEAM) ", ply:Nick(), color_white, ": ", Color(R, G, B, A), strText)
return true
end
end
end
end
if !IsValid(ply) and !ply:IsPlayer() then
local ConsoleColor = Color(0, 255, 0) --Change this to change Console name color
chat.AddText(ConsoleColor, "Console", color_white, ": ", strText)
return true
end
end )

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Chat prefixes/tags/titles/names
« Reply #5 on: August 29, 2013, 01:51:07 PM »
Psst. Megiddo. Stop waking up posts from 2012.
:P
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Chat prefixes/tags/titles/names
« Reply #6 on: August 29, 2013, 08:54:08 PM »
He didn't. :D As far as I can tell.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Chat prefixes/tags/titles/names
« Reply #7 on: August 30, 2013, 03:03:44 PM »
Oops.
Psst. Hey, Dimstar, no need to wake up posts from 2012.
(Though, admittedly, your post does answer a question...even if it was over a year ago asked)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Chat prefixes/tags/titles/names
« Reply #8 on: August 30, 2013, 03:09:22 PM »
The only thing I can think of is people find these posts using the search feature (Either through the website or through a search engine). Ergo: You should be quite thrilled Jam! :D

Offline Wully616

  • Jr. Member
  • **
  • Posts: 64
  • Karma: 10
    • WullysGamers
Re: Chat prefixes/tags/titles/names
« Reply #9 on: September 01, 2013, 04:33:26 AM »
I have this script on my server, no idea where I got it, but it seems to work fine except some of the colours of the ranks come out white. I haven't really tried investigating it because it hasn't bothered me before.



prefix.lua in garrysmod/addons/ulx/lua/ulx/modules/cl

Code: [Select]
    function insertChatTags(ply, msg)
            if ply:IsValid() then
                    local ply_team = ply:Team()
                    local team_name = team.GetName( ply_team )
                   
                    --local h,s,v = ColorToHSV( team.GetColor( ply_team ) )
                    --local comp_col = HSVToColor( 180-h, s, v )
                   
                   
                    --PHX-Server specifics
                    if ( team_name == "Leader Builder" ) then

                            comp_col = Color(55,126,206)
                    elseif ( team_name == "Admin Builder" ) then

                            comp_col = Color(79,115,158)       
                    elseif ( team_name == "Wullys Builder" ) then
 
                            comp_col = Color(0,178,255)
                    elseif ( team_name == "Ultimate Builder" ) then

                            comp_col = Color(121,0,221)
                    elseif ( team_name == "Precision Builder" ) then

                            comp_col = Color(0,147,12)
                    elseif ( team_name == "Loyal Builder" ) then

                            comp_col = Color(173,0,23)
                    elseif ( team_name == "Creative Builder" ) then

                            comp_col = Color(0,13,132)
                    elseif ( team_name == "Novice Builder" ) then

                            comp_col = Color(255,242,0)
                    elseif ( team_name == "Bronze Builder" ) then

                            comp_col = Color(135,81,0)   
                    elseif ( team_name == "Silver Builder" ) then

                            comp_col = Color(135,135,135)   
                    elseif ( team_name == "Gold Builder" ) then
                         
                            comp_col = Color(237,197,0)   
                    elseif ( team_name == "Respected" ) then
                            comp_col = Color(169,186,198)                               
                    elseif ( team_name == "user" ) then   
                            comp_col = Color(100,100,100)
                            team_name = "New Builder"
                    else
                            comp_col = Color(255, 255, 255)
                    end
                   
                   
                    chat.AddText( team.GetColor( ply_team ), "[",comp_col, team_name,team.GetColor( ply_team ), "] ", ply:GetName(), color_white, ": ", msg )
                    return true
            end
    end
     
    hook.Add( "OnPlayerChat", "ulx_chattags", insertChatTags )
[/url]