Skip to content

Commit 198bb8b

Browse files
committed
README: Update section about hooks
1 parent be1c224 commit 198bb8b

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ _(A list of fonts can be found on the workshop page.)_
5151

5252
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](https://steamcommunity.com/workshop/filedetails/discussion/2799307109/3272437487156558008/).
5353

54-
### For developers
54+
## For developers
55+
56+
### Hook: CanEmbedCustomChat
5557

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

@@ -70,23 +72,54 @@ hook.Add( "CanEmbedCustomChat", "chat_embed_access_example", function( ply, url,
7072
end )
7173
```
7274

73-
You can add more or override chat tags via code, using this hook on the **client side**:
75+
### Hook: OverrideCustomChatTags
76+
77+
You can add/override chat tags dynamically via code, using this hook on the **client side**:
7478

7579
```lua
7680
hook.Add( "OverrideCustomChatTags", "custom_tags_example", function( ply )
77-
-- A sequential table with strings, colors or anything really
81+
-- A sequential table with strings, colors or anything that can be passed to `tostring()`
7882
local parts = {
7983
color_black, "(", Color( 0, 0, 255 ), "The " .. team.GetName( ply:Team() ), color_black, ") "
8084
}
8185

8286
-- Should we keep the original custom tags that
8387
-- were added on the "[Admin] Chat Tags" menu?
88+
-- Set this to false to only use the parts you've added in here.
8489
local keepOriginalParts = true
8590

8691
return parts, keepOriginalParts
8792
end )
8893
```
8994

95+
### Hook: OverrideCustomChatPlayerColor
96+
97+
You can use this hook on the **client side** to override the colors that will be shown for player names.
98+
99+
```lua
100+
hook.Add( "OverrideCustomChatPlayerColor", "custom_player_color_example", function( ply )
101+
-- Make the name color for dead players red.
102+
if not ply:Alive() then
103+
return Color( 255, 0, 0 )
104+
end
105+
106+
-- If you return two colors, the player name will have a gradient/glow effect.
107+
if ply:IsSuperAdmin() then
108+
return Color( 255, 0, 0 ), Color( 0, 100, 255 )
109+
end
110+
111+
-- Return nothing to keep the default behaviour from Custom Chat.
112+
end )
113+
```
114+
115+
### Hook: CustomChatBlockInput
116+
117+
You can return `true` on this hook to block the "open chat" button(s). It runs on the **client side**.
118+
119+
### Hook: CustomChatHideJoinMessage
120+
121+
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](https://wiki.facepunch.com/gmod/gameevent/player_connect_client#members) hook.
122+
90123
## Contributing
91124

92125
Before you open a pull request, please read [this](https://github.com/StyledStrike/gmod-custom-chat/blob/master/.github/pull_request_template.md).

0 commit comments

Comments
 (0)