Hooks hooks
Part of Chat Box
Hooks called by Chat Box
Summary
Hooks
Chatbox.compile returns it.Hooks
Lets plugins change a message before it is checked against a listener and sent to them. Called on the server once for every potential listener. Every listener gets their own copy of the message data, so a change made for one of them does not affect the others.
Parameters
- listener Player the player who may receive the message
- message_data Map message data: data (the pieces), sender, position, radius, size and the other options given to Chatbox.add_text
Called from
Call sites
Lets plugins alter or replace the message a player is about to say. Called on the server
by Chatbox.player_say once the default message has been put together, before it is
passed to Chatbox.add_text.
Parameters
- actor Player the speaker
- text String the text being said, without surrounding whitespace
- message List arguments for Chatbox.add_text: the icon, the name color, the speaker, the text color, ': ', the text and the options table; modify it in place. While the 'chat_avatars' config is enabled the avatar of the speaker (see Chatbox.avatar) comes right after the icon, moving the rest one place further
Called from
Call sites
Lets plugins compile a whole message themselves. Called on the client by
Chatbox.compile before the pieces of the message are compiled; gamemode hooks are not
called.
Parameters
- data List pieces of the message as they were received from the server
- compiled Map compiled message to fill in; it already holds the initial font size, and its total_height field should be set to the height of the message
Returns
- Boolean return true to skip the default compilation of all pieces
Called from
Call sites
Lets plugins compile a single piece of a message. Called on the client for every piece in order, unless ChatboxCompileMessage has taken over the whole message; gamemode hooks are not called.
Parameters
- piece Any a string, font size, color, icon, image or avatar table, player or entity
- compiled Map the message compiled so far, to append to
Returns
- Boolean return true to skip the default handling of this piece
Called from
Call sites
Provides the color of the text of what a player says. Called on the server by
Chatbox.player_say. The Chatbox plugin's own handler supplies white.
Parameters
- actor Player the speaker
- text String the message
- team_chat Boolean whether the message is meant for the team chat
Returns
- Color color of the text; white when nothing is returned
Called from
Call sites
Provides the color of the name of a player in what they say. Called on the server by
Chatbox.player_say. The Chatbox plugin's own handler supplies the team color.
Parameters
- actor Player the speaker
- text String the message
- team_chat Boolean whether the message is meant for the team chat
Returns
- Color color of the name; the color of the speaker's team when nothing is returned
Called from
Call sites
Provides the icon displayed before the name of a player in what they say. Called on
the server by Chatbox.player_say. The Chatbox plugin's own handler supplies the
default icon.
Parameters
- actor Player the speaker
- text String the message
- team_chat Boolean whether the message is meant for the team chat
Returns
- Map icon piece for Chatbox.add_text; no icon is shown when nothing is returned
Called from
Call sites
Called on the client when a message has been compiled, before Chatbox.compile returns
it. The Chatbox plugin itself uses it to print the message to the console.
Parameters
- compiled Map the compiled message; changes made to it are kept
Called from
Call sites
Called on the server after a chat message has been sent to everyone who can hear it.
Not called for a message that ChatboxShouldSendMessage has canceled, nor for the text
that a client adds with chat.AddText.
Parameters
- message_data Map message data as it was before the AdjustMessageData hook changed the copies of the listeners: data (the pieces), sender, position, radius, size, time and the other options given to Chatbox.add_text
- receivers List<Player> the players the message has been sent to, in the order they received it; empty if nobody could hear it
Called from
Call sites
Lets plugins draw a chat message themselves. Called on the client every frame for each message that is visible, while its panel is being painted; gamemode hooks are not called.
Parameters
- w Number width of the message panel
- h Number height of the message panel
- panel Panel the fl_chat_message panel; its message_data field holds the compiled message and its alpha field the current opacity
Returns
- Boolean return true to skip the default drawing
Called from
Call sites
Decides whether a message received from the server is added to the chatbox. Called on the client before the message is compiled; gamemode hooks are not called.
Parameters
- message_data Map message data received from the server
Returns
- Boolean return false to drop the message
Called from
Call sites
Decides whether a chat message is sent at all. Called on the server by
Chatbox.add_text once the message has been put together, before the AdjustMessageData
and PlayerCanHear hooks are run for its listeners. Not called for the text that a client
adds with chat.AddText, which only that client receives.
Parameters
- message_data Map message data: data (the pieces), sender, position, radius, size, time and the other options given to Chatbox.add_text; a change made to it applies to every listener
- listeners List<Player> the players the message is meant for, before it is checked who of them can hear it
Returns
- Boolean return false to cancel the message, so that nobody receives it and ChatboxMessageSent is not run
Called from
Call sites
Called on the client when the player presses enter in the chatbox. The handler of the Chatbox plugin itself sends the text to the server and closes the chatbox.
Parameters
- text String contents of the text entry, which may be empty
Call sites
The ChatTextChanged hook of GMod, run by the chatbox because it replaces the default
chat. Called on the client whenever the contents of the text entry change, and with an
empty string when the chatbox is closed by Chatbox.hide.
Parameters
- text String current contents of the text entry
Called from
Call sites
Asks for the name to display for a player, here while a message is being turned
into a string. It is the hook behind Player:name; Chatbox.compile also runs it
on the client for the players in a message, unless the ShouldProcessPlayerName hook
returns false.
Parameters
- target Player
Returns
- String name to use instead of the name of the player
Called from
Call sites
Lets plugins make a listener receive a message regardless of its radius. Called on the
server by Chatbox.can_hear before the radius is checked; gamemode hooks are not called.
Parameters
- listener Player
- message_data Map message data, see Chatbox.add_text
Returns
- Boolean return true to let the listener receive the message. Any other value leaves the decision to the radius check, so a handler cannot block a message
Called from
Call sites
The PlayerSay hook of GMod, run by the chatbox itself: chat typed into the chatbox is
sent through its own network message, so the engine never runs the hook for it. Called on
the server before the text is turned into a chat message. The engine runs the same hook
for the say console command, where the plugin's own Chatbox:PlayerSay handler takes
the text over.
Parameters
- actor Player the speaker
- text String the text as it was typed
- team_chat Boolean whether the message is meant for the team chat, as sent by the chatbox of the speaker; nil when Chatbox.player_say is called without it
Returns
- String text to say instead; an empty string suppresses the message, which is how commands are kept out of the chat
Called from
Call sites
Decides whether a message may be removed from the chatbox. Called on the client when the history is full and its oldest message is about to be ejected; gamemode hooks are not called.
Parameters
- panel Panel the fl_chat_message panel
Returns
- Boolean return false to keep the message
Called from
Call sites
Decides whether the name of a player in a message goes through the
GetPlayerName hook. Called on the client by Chatbox.compile for every
player that is part of a message.
Parameters
- target Player the player whose name is displayed
- message_data Map message data received from the server
Returns
- Boolean return false to display the true name of the player