Ulysses

Ulysses Stuff => General Chat & Help and Support => Topic started by: Willdy on August 22, 2011, 05:24:48 PM

Title: Chat Prefix
Post by: Willdy 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
Title: Re: Chat Prefix
Post by: Megiddo 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.
Title: Re: Chat Prefix
Post by: spbogie 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.