/gmod-custom-chat

A customizable chat box for Garry's Mod.

Primary LanguageLuaMIT LicenseMIT

Custom Chat

A simple and customizable chat box that can format text, display images and emojis.

GLuaLint Workshop Page

Features

  • Customizable
  • Has built-in emojis
  • Has a direct message/chat channels system
  • Supports text formatting (bold, italic, fonts, code blocks, etc.)
  • Embed image/audio files (Only loads from trusted websites by default)
  • Find text with Ctrl+F
  • Shows icons for prop models
  • Keeps the default "hands on ear when the chat is open" behaviour
  • Can be enabled/disabled at any time (Using the custom_chat_enable console variable)
  • (Admin Only) Set a theme to be used on your server
  • (Admin Only) Set custom emojis
  • (Admin Only) Set custom chat tags
  • (Admin Only) Set custom join/leave messages

Text Formatting Options

||Spoilers here||
*Italic text here*
**Bold text here**
***Bold & Italic text here***
$$rainbow text here$$
`line of code here`
{{block of code here}}
```block of code here```
[[Marquee-like advert here]]
[Link text Here](https://link-url-here.org)
<255,0,0>Red text here, and <0,0,255>blue text here

Fonts

You can change the font by typing ;fontname; before the text. (A list of fonts can be found on the workshop page.)

;comic; This will be displayed as Comic Sans

Whitelisted Sites

By default, the chat box will only load pictures from trusted websites. You can open a pull request to add more, or send a request here.

For developers

You can prevent links from certain players from embedding, by using the CanEmbedCustomChat hook on the client side:

hook.Add( "CanEmbedCustomChat", "chat_embed_access_example", function( ply, url, urlType )
    -- return false to block embeds from "url"

    -- "urlType" will be one of these strings:
    -- "image", "audio", and "url" for other things

    -- Example: only allow super admins to use embeds
    if not ply:IsSuperAdmin() then return false end

    -- Example: prevent audio from embedding for everyone
    if urlType == "audio" then return false end
end )

You can add more or override chat tags via code, using this hook on the client side:

hook.Add( "OverrideCustomChatTags", "custom_tags_example", function( ply )
    -- A sequential table with strings, colors or anything really
    local parts = {
        color_black, "(", Color( 0, 0, 255 ), "The " .. team.GetName( ply:Team() ), color_black, ") "
    }

    -- Should we keep the original custom tags that
    -- were added on the "[Admin] Chat Tags" menu?
    local keepOriginalParts = true

    return parts, keepOriginalParts
end )

Contributing

Before you open a pull request, please read this.