Skip to content

StyledStrike/gmod-custom-chat

Repository files navigation

Custom Chat

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

GLuaLint Workshop Page

Table of contents

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

||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
$255,0,0,0,100,255$(red-to-blue gradient 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.

Developer reference

Hooks (quick links)

CanEmbedCustomChat

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 )

CanFormatCustomChat

You can block specific text formatting types per-player on the client using the CanFormatCustomChat hook. Return false to prevent that formatting from being applied; the text will be shown as plain text instead.

hook.Add( "CanFormatCustomChat", "format_access_example", function( ply, formatType, value )
    -- Return false to block this formatting for this player/message

    -- formatType is one of:
    -- "url", "hyperlink", "gradient", "model", "font",
    -- "italic", "bold", "bold_italic", "color", "rainbow",
    -- "advert", "emoji", "spoiler", "code_line", "code"

    -- Example: only allow admins to use gradients
    if formatType == "gradient" and not ply:IsAdmin() then
        return false
    end

    -- Example: block spoilers for everyone
    if formatType == "spoiler" then
        return false
    end

    -- Example: restrict links to super admins
    if (formatType == "url" or formatType == "hyperlink") and not ply:IsSuperAdmin() then
        return false
    end
end )

OverrideCustomChatTags

You can add/override chat tags dynamically 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 that can be passed to `tostring()`
    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?
    -- Set this to false to only use the parts you've added in here.
    local keepOriginalParts = true

    return parts, keepOriginalParts
end )

OverrideCustomChatPlayerColor

You can use this hook on the client side to override the colors that will be shown for player names.

hook.Add( "OverrideCustomChatPlayerColor", "custom_player_color_example", function( ply )
    -- Make the name color for dead players red.
    if not ply:Alive() then
        return Color( 255, 0, 0 )
    end

    -- If you return two colors, the player name will have a gradient/glow effect.
    if ply:IsSuperAdmin() then
        return Color( 255, 0, 0 ), Color( 0, 100, 255 )
    end

    -- Return nothing to keep the default behaviour from Custom Chat.
end )

CustomChatBlockInput

You can return true on this hook to block the "open chat" button(s). It runs on the client side.

CustomChatHideJoinMessage

You can return true on this hook to dynamically prevent join/leave messages from showing up. It runs on the client side, and gives a data table as a argument, that contains the same keys given by the player_connect_client hook.

Contributing

Before you open a pull request, please read this.

About

A customizable chat box for Garry's Mod.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors 10

Languages