cityrp.chatBox
Clientside code relating to the chatbox.
- Clientcityrp.chatBox.createDermaAll()Source ☍
-
Creates every chatbox derma panel and hides the main chat panel.
- Clientcityrp.chatBox.getButtonHeight() → numberSource ☍
-
Height of the scroll and filter buttons. Fills the bar rather than sitting at a fixed 16px, so they are a real target at any chat text size.
Returns
- numberbutton height in pixels.
- Clientcityrp.chatBox.getButtonStripWidth() → numberSource ☍
-
Total width the button strip occupies at the right of the bar, including the gap that separates it from the text entry.
Returns
- numberreserved width in pixels.
- Clientcityrp.chatBox.getHorizontalPadding() → numberSource ☍
-
Horizontal inset between the log backdrop and message content. Keeps rank icons off the panel edge without shifting the backdrop away from the input bar below it.
Returns
- numberin pixels.
- Clientcityrp.chatBox.getInputEntryHeight() → numberSource ☍
-
Height of the chat text entry inside the bar.
Returns
- numberentry height in pixels.
- Clientcityrp.chatBox.getInputHeight() → numberSource ☍
-
Height of the chat input bar, derived from the chat font rather than fixed. The bar used to be a hardcoded 24px, so raising cityrp_chatbox_textsize clipped the top off the text.
Returns
- numberbar height in pixels.
- Clientcityrp.chatBox.getPosition() → number, numberSource ☍
-
Gets the chatbox position.
Returns
- 1numberThe current X position.
- 2numberThe current Y position.
- Clientcityrp.chatBox.getSpacing() → numberSource ☍
-
Gets the chatbox's spacing between messages. Spacing scales with font size to prevent overlap.
Returns
- numberdistance.
- Clientcityrp.chatBox.getWidth() → numberSource ☍
-
Gets the chatbox width for the current screen resolution.
Returns
- numberchatbox width in pixels.
- Clientcityrp.chatBox.getX() → numberSource ☍
-
Gets the chatbox's x position.
Returns
- numberThe current X position.
- Clientcityrp.chatBox.getY() → numberSource ☍
-
Gets the chatbox's y position.
Returns
- numberThe current Y position.
- Clientcityrp.chatBox.layoutButtons(chatWidth, barHeight)Source ☍
-
Positions the scroll and filter buttons against the current bar geometry. Laid out from the right edge so the strip stays together whatever the width.
Parameters
- chatWidthnumberCurrent width of the input bar.
- barHeightnumberCurrent height of the input bar.
- Clientcityrp.chatBox.wrapText(text, font, width, overhead, base)Source ☍
-
Provides a table of wrapped strings.
Parameters
- textstringThe string to wrap.
- fontstringThe font to check widths against.
- widthnumberMaximum line width to explode at.
- overheadnumber?The buffer between text width and maximum width for the first line.
- basetableTable to insert the lines in.
- Clientchat.AddText(_)Source ☍
-
Overrides the stock chat.AddText to add text to the chatbox as well as the console. Currently semi-broken: matching a system message to a chatbox entry requires a manual catch to be added to
catchesabove.Parameters
- string|number|PlayerVararg; players are converted to their name, strings are taken as-is, numbers are stringified, and other values are discarded.
- Clientcityrp.chatBox:addGenericAction(class, func)Source ☍
-
Registers a handler for a generic (non-player-originated) chat message class.
Parameters
- classstringThe message class to handle.
- funcfun(...any)The handler function.
- Clientcityrp.chatBox:addPlayerAction(class, func)Source ☍
-
Registers a handler for a player-originated chat message class (e.g. "ic", "advert"). Rendering functions registered by name are resolved to whatever function is currently registered under that name at call time.
Parameters
- classstringThe message class to handle.
- funcstring|fun(...any)The handler function, or the name of another registered class to alias.
- Clientcityrp.chatBox.getInputBackground() → ColorSource ☍
-
Backdrop colour for the chat input bar and the filter box. Follows the log panel's tint and opacity so the two read as one surface. The bar was fixed at black 150 regardless of the setting, so raising the opacity or tinting the log left the bar a visibly different shade to the panel sitting directly above it.
Only once the panel is actually switched on, though. With it off there is nothing above the bar to match, and tinting the bar on its own would just recolour a surface the player never asked to change.
Returns
- ColorThe colour to fill the bar with.
- Clientcityrp.chatBox.getInputOffset() → numberSource ☍
-
How far below the chat position the input bar sits. getPosition has to know this to keep the bar clear of the HUD, so it is shared rather than repeated. Gap between the chat position and the top of the input bar. Derived from the line spacing rather than fixed, so it keeps pace with the chat text size. The newest message's baseline sits barely above the chat position, and a flat 6px left the bar sitting on top of that last line.
Returns
- numberoffset in pixels.
- Servercityrp.chatBox.add(recipientFilter, ply, filter, text, color)Source ☍
-
Adds a new chatbox line, optionally attributed to a player.
Parameters
- recipientFilter(CRecipientFilter|Player|table<integer, Player>)?Players to send the message to, or nil to broadcast.
- plyPlayer?Player who is making the message, or nil for a system message.
- filterstringThe type of message being sent.
- textstringThe message body.
- colorColor?Optional custom color for the message.
- Servercityrp.chatBox.addInRadius(ply, filter, text, position, radius)Source ☍
-
Adds a new chatbox line to players within a radius of a position.
Parameters
- Clientcityrp.chatBox.chatText(index, name, text, class, customColor)Source ☍
-
Processes an incoming chat message and routes it to the appropriate chatbox rendering, based on its class and whether it originated from a player. Called when a player says something or a message is received from the server.
Parameters
- index(number|table|Player)?The sending player's UserID, entity, or player data table; nil/0 for non-player-originated messages.
- namestringThe display name to use for the message.
- textstringThe message text.
- classstringThe message class, e.g. "ic", "ooc", "radio".
- customColorColor?Custom colour override for the message, where the class supports it.
- Clientcityrp.chatBox.createDermaButton(name, text, x, width, toolTip, doClick, think)Source ☍
-
Creates a derma button parented to the chatbox panel, if one with the given name doesn't already exist.
Parameters
- namestringThe internal name of the button.
- textstringThe label of the button.
- xnumberThe x position of the button.
- widthnumberThe width of the button.
- toolTipstringThe hover text for the button.
- doClickfun()Called when the button is clicked.
- thinkfun(self: Panel)Called every frame; typically used to update the button's disabled state.
- Clientcityrp.chatBox.createDermaButtons()Source ☍
-
Creates the chatbox control buttons (scroll up/down, bottom, filters), if they don't already exist.
- Clientcityrp.chatBox.createDermaCheckBox(name, conVar, x, toolTip, label, parent, y)Source ☍
-
Creates a derma check box (optionally labelled) parented to the chat panel, if one with the given name doesn't already exist.
Parameters
- namestringThe internal name of the checkbox.
- conVarstringThe attached ConVar to change.
- xnumberThe x position of the checkbox.
- toolTipstringThe hover text for the checkbox.
- labelstring?The label for the checkbox; if omitted, a plain DCheckBox is created instead of a DCheckBoxLabel.
- parentPanel?Parent for the checkbox, defaults to the chat panel.
- ynumber?The y position to put the checkbox, defaults to 4.
- Clientcityrp.chatBox.createDermaCheckBoxes()Source ☍
-
Initializes the derma.checkBoxes table if it doesn't already exist.
- Clientcityrp.chatBox.createDermaFilters()Source ☍
-
Creates the filter panel and its check boxes (OOC, LOOC, IC, radio, join/leave), if it doesn't already exist.
- Clientcityrp.chatBox.createDermaPanel()Source ☍
-
Creates the main chat input panel, its scroll panel, and their show/hide helpers, if the panel doesn't already exist.
- Clientcityrp.chatBox.createDermaTextEntry()Source ☍
-
Create the derma text entry.
- Clientcityrp.chatBox.derma.filters:Paint()Source ☍
-
Called every time the panel should be painted.
- Clientcityrp.chatBox.derma.filters:Think()Source ☍
-
Called every frame.
- Clientcityrp.chatBox.derma.panel.hide()Source ☍
-
A function to hide the chat panel.
- Clientcityrp.chatBox.derma.panel:Paint()Source ☍
-
Called every time the panel should be painted.
- Clientcityrp.chatBox.derma.panel.show(team, text)Source ☍
-
Parameters
- teamany
- textany
- Clientcityrp.chatBox.derma.panel:Think()Source ☍
-
Called eveyr frame.
- Clientcityrp.chatBox.derma.scroll:OnMouseWheeled(delta)Source ☍
-
Called when the panel is scrolled with the mouse wheel.
Parameters
- deltaany
- Clientcityrp.chatBox.derma.textEntry.OnEnter()Source ☍
- Clientcityrp.chatBox.derma.textEntry:OnKeyCodeTyped(key) → unknownSource ☍
-
Parameters
- keyany
Returns
- unknown
- Clientcityrp.chatBox.derma.textEntry:OnTextChanged()Source ☍
- Clientcityrp.chatBox.derma.textEntry:Think()Source ☍
-
Called every frame.
- Clientcityrp.chatBox.explodeByTags(variable, seperator, open, close) → tableSource ☍
-
Explodes a string on a separator, treating any run of characters between an open and close tag as a single unbreakable piece.
Parameters
- variablestringThe input string to explode.
- seperatorstringThe separator to explode by.
- openstringThe opening tag.
- closestringThe closing tag.
Returns
- tableThe exploded pieces, in order.
- Clientcityrp.chatBox.extractClasses(message)Source ☍
-
Wraps a message's text into rendered blocks, populating message.blocks and message.lines in place.
Parameters
- messagetableThe message table, as built by messageAdd.
- Clientcityrp.chatBox.hudPaint()Source ☍
-
Called on HUDPaint.
- Clientcityrp.chatBox.messageAdd(title, name, text, filtered, icon, consoleSuffix)Source ☍
-
Builds a message from its parts, extracts it into wrapped blocks, prints it to console, and (unless filtered) adds it to the chatbox and history.
Parameters
- title{ [1]: string, [2]: Color }?The title text and colour, e.g. a message class label.
- name{ [1]: string, [2]: Color }?The sender name text and colour.
- text{ [1]: string, [2]: Color }The message text and colour.
- filteredboolean?Whether the message is filtered and thus should not be displayed in the chatbox (still printed to console).
- icon{ [1]: string, [2]: string }?The icon for the message: a material path (without extension) and a fallback character to print in console.
- consoleSuffixstring?A prefix to put before the message text in console.
- Clientcityrp.chatBox.playerBindPress(player, bind, press) → boolean?Source ☍
-
Handles the toggleconsole/messagemode/messagemode2 binds, opening or closing the chat panel as appropriate. Hooked to PlayerBindPress below.
Parameters
- playerPlayerThe local player who pressed the bind.
- bindstringThe bind which was pressed.
- pressbooleanWhether the bind is being pressed (true) or released (false).
Returns
- boolean?True if the engine's default action for the bind should be suppressed.
- Clientcityrp.chatBox.printConsole(message)Source ☍
-
Prints a built message table to console, one line per block that ends in a newline.
Parameters
- messagetableThe message table, as built by messageAdd and extracted by extractClasses.
- Clientcityrp.chatBox.rewrapAll()Source ☍
-
Re-wraps every stored message against the current width and font. Wrapping is baked in when a message arrives, so without this a width or text size change would only affect messages received after it.
- Clientcityrp.chatBox.think()Source ☍
-
Think hook function for the chatbox.
Functions
Globals
Internals
- Clientcityrp.chatBox.actionsSource ☍
- Clientcityrp.chatBox.actions.genericSource ☍
- Clientcityrp.chatBox.actions.playerSource ☍
- Clientcityrp.chatBox.dermaSource ☍
-
Client derma store.
- Clientcityrp.chatBox.derma.buttonsSource ☍
- Clientcityrp.chatBox.derma.checkBoxesSource ☍
- Clientcityrp.chatBox.historySource ☍
-
Table to store the chat history.
- Clientcityrp.chatBox.history.messagesSource ☍
-
Recently recieved messages in the history.
- Clientcityrp.chatBox.joinSpamSource ☍
-
List of messages spamming join.
- Clientcityrp.chatBox.leaveSpamSource ☍
-
List of messages spamming leave.
- Clientcityrp.chatBox.messagesSource ☍
-
Recent message.
- Clientcityrp.chatBox.sendhistorySource ☍
-
Table to store the sent chat history.
- Clientcityrp.chatBox.sendhistory.messagesSource ☍
-
Table to store the chat message sent.
- Clientcityrp.chatBoxSource ☍
- Sharedcityrp.chatBox.actionTypesSource ☍
- Clientcityrp.chatBox.derma.filtersSource ☍
- Clientcityrp.chatBox.derma.panelSource ☍
- Clientcityrp.chatBox.derma.panel.lastHeightSource ☍
- Clientcityrp.chatBox.derma.panel.lastWidthSource ☍
- Clientcityrp.chatBox.derma.scrollSource ☍
-
Create the scroll panel.
- Clientcityrp.chatBox.derma.textEntrySource ☍
- Clientcityrp.chatBox.history.positionSource ☍
-
Current cursor position within history.
- Clientcityrp.chatBox.maximumLinesSource ☍
- Clientcityrp.chatBox.sayTeamSource ☍
- Clientcityrp.chatBox.sayTextSource ☍
- Clientcityrp.chatBox.sendhistory.positionSource ☍
-
Store the history cursor pos.
- Clientcityrp.chatBox.sendhistory.usepositionSource ☍
-
Store for the current used position.