💬 Chat
Configure, envoie et intercepte les messages du Chat.
🎒 Exemples
(Chat.BroadcastMessage) Sends a message to everyone
Chat.BroadcastMessage("Welcome to the server!")
(Chat.Submit) Forwards a message from a custom chat interface
Events.SubscribeRemote("MyChatSubmit", function(player, message)
if (not Chat.Submit(player, message)) then
Chat.SendMessage(player, "Your message was not sent")
end
end)
Colors in Chat
It is also possible to send colored messages in the Chat! For that, just circumvent a piece of text with a style tag: \<TAG>my awesome text</>.
Server/Index.lua
Chat.BroadcastMessage("Hello with <cyan>Cyan</> text message!")
Liste des tags de style:
\<cyan> \<green> \<blue> \<purple> \<marengo> \<yellow> \<orange> \<red> \<grey> \<bold> \<italic>
note
It is NOT possible to combine two or more styles together (e.g. \<bold> + \<red>).
🗿 Fonctions statiques
| Returns | Name | Description | |
|---|---|---|---|
AddMessage | Ajoute un message dans le Chat qui s'affichera localement | ||
BroadcastMessage | Envoie un message dans le Chat de tous les joueurs | ||
Clear | Efface tous les messages | ||
SendMessage | Envoie un message dans le Chat à un joueur spécifique | ||
SetConfiguration | Configure l'apparence et la position du Chat | ||
SetVisibility | Définit si le Chat est visible ou non | ||
| boolean | Submit | Submits a chat message as if the Player had typed it in the chat | |
| function | Subscribe | Subscribes to an Event | |
Unsubscribe | Unsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback |
Moderate

AddMessage
Ajoute un message dans le Chat qui s'affichera localement
Chat.AddMessage(message)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | message | Required parameter | The message, supports the same rich text tags as the chat |
Moderate

BroadcastMessage
Envoie un message dans le Chat de tous les joueurs
Chat.BroadcastMessage(message)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | message | Required parameter | Le message à envoyer à tous les joueurs |
Chat.BroadcastMessage Examples
Sends a message to everyone
Chat.BroadcastMessage("Welcome to the server!")
Moderate

Clear
Efface tous les messages
Chat.Clear()
Optimal

SendMessage
Envoie un message dans le Chat à un joueur spécifique
Chat.SendMessage(player, message)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Player | player | Required parameter | Le joueur qui recevra le message |
| string | message | Required parameter | Le message |
Moderate

SetConfiguration
Configure l'apparence et la position du Chat
Chat.SetConfiguration(screen_location?, size?, anchors_min?, anchors_max?, alignment?, justify?, show_scrollbar?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector2D | screen_location? | Vector2D(-25, 0) | Screen location, or the left and top offsets when the anchors are stretched |
| Vector2D | size? | Vector2D(600, 250) | Size, or the right and bottom offsets when the anchors are stretched |
| Vector2D | anchors_min? | Vector2D(1, 0.5) | Min anchor, from (0, 0) top-left to (1, 1) bottom-right |
| Vector2D | anchors_max? | Vector2D(1, 0.5) | Max anchor, from (0, 0) top-left to (1, 1) bottom-right |
| Vector2D | alignment? | Vector2D(1, 0.5) | Pivot of the chat, (0.5, 0.5) is the center |
| boolean | justify? | true | Whether the text is justified |
| boolean | show_scrollbar? | true | Whether to show the scrollbar |
Optimal

SetVisibility
Définit si le Chat est visible ou non
Chat.SetVisibility(is_visible)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| boolean | is_visible | Required parameter | Whether the Chat is visible or not |
Moderate

Submit
Submits a chat message as if the Player had typed it in the chat, also triggering the PlayerSubmit event
local ret = Chat.Submit(player, message)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Player | player | Required parameter | The player who is sending the message |
| string | message | Required parameter | Le message |
Returns
| Type | Description |
|---|---|
| boolean | false if a PlayerSubmit handler cancelled the message, true if it was broadcast |
Chat.Submit Examples
Forwards a message from a custom chat interface
Events.SubscribeRemote("MyChatSubmit", function(player, message)
if (not Chat.Submit(player, message)) then
Chat.SendMessage(player, "Your message was not sent")
end
end)
Optimal

Subscribe
Subscribes to an Event
local ret = Chat.Subscribe(event_name, callback)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | event_name | Required parameter | Event to subscribe to |
| function | callback | Required parameter | Callback to run on the event occurring |
Returns
| Type | Description |
|---|---|
| function | The function callback |
Optimal

Unsubscribe
Unsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback
Chat.Unsubscribe(event_name, callback?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | event_name | Required parameter | Event to unsubscribe to |
| function | callback? | nil | Optional callback to specifically unsubscribe to |
🚀 Événements
| Name | Description | |
|---|---|---|
ChatEntry | Appelé lorsqu'un nouveau message de chat est reçu ; se déclenche également lorsque des messages sont envoyés par programmation | |
Close | Lorsqu'un joueur ferme le Chat | |
Open | Quand le joueur ouvre le Chat | |
PlayerSubmit | Appelé lorsqu'un joueur envoie un message dans le Chat |

ChatEntry
Appelé lorsqu'un nouveau message de chat est reçu ; se déclenche également lorsque des messages sont envoyés par programmation.
Utile pour créer votre propre interface de chat tout en conservant le système intégré
Chat.Subscribe("ChatEntry", function(message, player)
-- ChatEntry was called
end)
Arguments
| Type | Argument | Description |
|---|---|---|
| string | message | Le message |
| Player or nil | player | Le joueur ayant envoyé le message, ou nil si l'appel a été effectué côté client ou via du code |

Close
Lorsqu'un joueur ferme le Chat
Chat.Subscribe("Close", function()
-- Close was called
end)

Open
Quand le joueur ouvre le Chat
Chat.Subscribe("Open", function()
-- Open was called
end)

PlayerSubmit
Appelé lorsqu'un joueur envoie un message dans le Chat
Renvoyez false pour empêcher l'envoi du message
Chat.Subscribe("PlayerSubmit", function(message, player)
-- PlayerSubmit was called
return true
end)

