ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. outputChatBox

Function

outputChatBox

Server and clientChat and consoleIdentical to MTA:SA

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 0 to 255.
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)

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.

See also