The Message table sends text to players. Strings are cut at a UTF-8 boundary if they are too long (NPC speech is at most 1024 bytes; the Message.Box / Message.BoxAll dialogs only hold 150 bytes of content and 100 bytes of title in the packet sent to the client). Functions that send to one player only need the character to be logged in (LOGGED or higher); if it is not valid, nothing is sent.

Notice types (type) of Message.Send, Message.SendAll, Message.SendGlobal: 0 yellow text in the middle of the screen, 1 blue text, 2 guild channel, 3 red text. The value is clamped to 0 to 255.

Text content should come from the language files (Message.GetText) or from the module's configuration file, not be hard-coded in the code, so it is easy to change and translate.

Message.Send

Sends a notice to one player.

Message.Send(aIndex, type, text)
ParameterTypeDescription
aIndexintegerIndex of the receiving character
typeintegerNotice type (default 1)
textstringContent

Short name: NoticeSend.

Message.Send(aIndex, 1, "You received 100 WCoin")

Message.SendAll

Sends a notice to every player on this GameServer.

Message.SendAll(type, text)
ParameterTypeDescription
typeintegerNotice type (default 0)
textstringContent

Short name: NoticeSendToAll.

Message.SendAll(0, "The event is about to start!")

Message.SendGlobal

Sends a notice to every player on all GameServers (through the inter-server connection, including this GameServer). If the inter-server connection is lost, the notice is only delivered within this GameServer.

Message.SendGlobal(type, text)
ParameterTypeDescription
typeintegerNotice type (default 0)
textstringContent

Short name: NoticeGlobalSend.

Message.SendGlobal(0, "The world boss has appeared!")

Message.Box

Shows a dialog box in the middle of one player's screen.

Message.Box(aIndex, type, title, text)
ParameterTypeDescription
aIndexintegerIndex of the receiving character
typeintegerDialog type (0 to 255, default 1)
titlestringTitle
textstringContent (the packet sent to the client holds at most 150 bytes; any excess is cut off)

Short name: MessageSend.

The type value is sent to the client as is (clamped to 0 to 255); GameServer does not process its meaning, and the client decides which dialog style is displayed. The content in the packet sent to the client is at most 150 bytes long and the title at most 100 bytes (any excess is cut at a UTF-8 boundary).

Message.Box(aIndex, 0, "Attendance", "You have received today's gift.")

Message.BoxAll

Shows a dialog box to every player currently in game on this GameServer.

Message.BoxAll(type, title, text)
ParameterTypeDescription
typeintegerDialog type (0 to 255, default 1)
titlestringTitle
textstringContent (the packet sent to the client holds at most 150 bytes; any excess is cut off)

Short name: MessageSendToAll.

Message.BoxAll(0, "Maintenance", "The server will restart in 5 minutes.")

Message.NpcSay

Makes an NPC (or monster) say a sentence. By default only a speech bubble is shown above the NPC's head; a line can also be added to the chat window.

Message.NpcSay(npcIndex, aIndex, text [, toChat])
ParameterTypeDescription
npcIndexintegerIndex of the active NPC / monster
aIndexintegerIndex of the player who hears it. -1 = everyone standing around the NPC
textstringContent (at most 1024 bytes)
toChatbooleantrue = also show a line "Name Say: ..." in the chat window; default false

The function does nothing if the NPC is not active or the listener is invalid. Short name: ChatTargetSend.

Message.NpcSay(npcIndex, aIndex, "Welcome to Lorencia!", false)

Message.Post

Sends a line of text in the style of the /post command to everyone on this GameServer.

Message.Post(name, text)
ParameterTypeDescription
namestringDisplay name of the sender (cut to the maximum length of a character name)
textstringContent (at most about 198 bytes; any excess is cut off)

Short name: PostSend(postType, msgIndex, name, text); the first two parameters are ignored.

Message.Post("System", "Happy New Year!")

Message.GetText

Gets a string from the server's language file (the Lang folder, structure <Group Type> / <Data ID>). There are two ways to call it.

Message.GetText(type, id, default) -> string
Message.GetText(id, default) -> string
ParameterTypeDescription
typeintegerGroup number (Group Type). The 2-parameter form uses group 0 (the System group)
idintegerString number (Data ID)
defaultstringString returned if not found

Returns: the string in the language file; if it does not exist, returns default. Short name: MessageGet(id, lang) (the lang parameter is ignored; returns an empty string by default).

local t = Message.GetText(0, 1, "Hello")