Author Topic: Chat Prefix  (Read 6901 times)

0 Members and 1 Guest are viewing this topic.

Offline Willdy

  • Jr. Member
  • **
  • Posts: 54
  • Karma: 1
Chat Prefix
« on: August 22, 2011, 05:24:48 PM »
Has this been developed at all? A small ULX addon which would put the group of a player before his name in chat.

[Admin] Willdy

Shouldn't be to hard to make, but it would be nice :o

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: Chat Prefix
« Reply #1 on: August 22, 2011, 06:03:06 PM »
Modifying chat is a can of worms, which is part of the reason we don't do this. It's unlikely that we'll ever support this in mainline ULX because of all the potential problems it raises.
Experiencing God's grace one day at a time.

Offline spbogie

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 456
  • Karma: 41
Re: Chat Prefix
« Reply #2 on: August 22, 2011, 08:31:16 PM »
Ugly, Untested, and Unsupported

Code: [Select]
local function lOnPlayerChat( ply, strText, bTeamOnly, bPlayerIsDead )
 
    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 ( bPlayerIsDead ) then
        table.insert( tab, Color( 255, 30, 40 ) )
        table.insert( tab, "*DEAD* " )
    end
 
    if ( bTeamOnly ) then
        table.insert( tab, Color( 30, 160, 40 ) )
        table.insert( tab, "(TEAM) " )
    end
 
    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 )
Set this up to run on the client side.

Yay, I'm contributing again :D. That was fun.
I have not failed. I've just found 10,000 ways that won't work. - Thomas A. Edison
I reject your reality and substitute my own. - Adam Savage