A Chat Command

Hey Guys, I need help making my own chat command. Here is what i need to happen:

When you type /ab Hey it says this:

[ADMIN] Players Name: Hey

It will be like OOC but instead it says [ADMIN]. I would also like it to print it in red if posible

I hope someone can help

Thanks

Nerosis

OnPlayerChat
chat.AddText
Hmm, didn’t pay attention to which thread it’s in. I guess it still stands, considering the first line.

Override the OnPlayerChat book clientside then print out the data with colours using chat.AddText.

i tryed to make the command byut didnt work, can someone write it for me please?

can anyone make this for me?

Shared version :

[LUA]
– Lolz

if SERVER then

local chat_command = "/ab";

local function OnChat( pl , text )
    if ( string.Explode( " " , text )[ 1 ] == chat_command ) then
        text = string.gsub( text , chat_command .. " ", "" )
        local tab = string.Explode( " " , text )
        umsg.Start( "ab" )
            umsg.Float( #tab )
            for k,v in ipairs( tab ) do
                umsg.String( v )
            end
        umsg.End()
        return ""
    end
end

hook.Add( "PlayerSay" , "ab chat command thingy" , OnChat )

else

usermessage.Hook( "ab" , function ( um ) 

    local tab = { }

    local amt = um:ReadFloat()
    for i=1 , amt do
        tab[ i ] = um:ReadString()
    end
    
    chat.AddText( Color( 255 , 0 , 0 ) , "[ADMIN]",
                    Color( 255 ,255 , 255 ) , unpack(tab) )
                    
    end
    
end)

end
[/LUA]

clientside version :

[LUA]
hook.Add( “OnPlayerChat” , “ab chat thingy” , function( pl , text )

local chat_command = "/ab"

if string.Explode( text , " " )[ 1 ] == chatcommand then

    local tab = {
    
        Color( 255 , 0 , 0 ) , "[ADMIN] ",
        Color( 155 , 0 , 255) , pl:Nick(),
        Color( 255 , 255 , 255) , " : " , string.gsub( text , chat_command .. " " , "" )

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

end)
[/LUA]

if you are the server owner i recommend the first version. otherwise the second version ( without script enforcer ) will only work for you. These are both untested , but if they dont work, atleast you get the idea :slight_smile: i hope :stuck_out_tongue: