- Documentation
- Shared functions
- outputChatBox
Function
outputChatBox
Writes a message in chat. On the server to one player or everyone, on the client in the local player's chat.
Syntax
Server
bool outputChatBox(string text [, element target = root, int r = 231, int g = 217, int b = 176, bool colorCoded = false])Client
bool outputChatBox(string text [, int r = 231, int g = 217, int b = 176, bool colorCoded = false])Arguments
textstring- The message.
targetelement, optional = root- Server only. The player who will see the message. Without it, everyone sees it.
r, g, bint, optional = 231, 217, 176- Message colour, from
0to255. colorCodedbool, optional = false- Enables colours in the text written like
#FF7A22.
Returns
true if the message was sent.
Example
addEventHandler("onPlayerJoin", root, function()
-- to everyone
outputChatBox(getPlayerName(source) .. " joined the game.")
-- only to the new player, with colours in the text
outputChatBox("#FF7A22Welcome! #FFFFFFType /help to see the commands.", source, 255, 255, 255, true)
end)
addCommandHandler("where", function()
local x, y, z = getElementPosition(localPlayer)
outputChatBox(("You are at %.1f, %.1f, %.1f"):format(x, y, z), 140, 196, 232)
end)
Notes
Difference between sides. On the client there is no target argument, because the message always goes to the chat of the player the script runs for. The colour comes right after the text.