Chat System

How the players talk in the game: room messages, private messages, global messages and the combat and system notifications, all saved in the database. The chat is the chat feature (enabled in Features).

How it works in the game

The chat icon opens the chat box, where the player writes the message and presses Enter or Send:

  • Room message - any text: every player in the same room gets it, and the text is shown over the player head for a few seconds.
  • Private message - @PlayerName message: only that player gets it, in any room. When the player is not connected the sender gets "Player not found".
  • Global message - #message: every connected player gets it, in any room. Only the roles of the server/chat/messages/global_allowed_roles config can send them.

The chat also shows when a player joins or leaves the room, the team and clan notifications, the damage, dodge and effect messages of the battles, and the errors. Each type has its color and the tabs (General, Private, Teams and Global in the sample data) filter them:

Reldens - Chat box with room, private, team and system messages, and the message over the player head Reldens - Private tab of the chat box

A player can send one message per second (the server/chat/messages/cooldownMs config, 1000 by default), the extra messages are ignored.

Managing the chat in the admin panel

The Chat section of the admin sidebar has two lists:

  • Chat - every saved message with the player, the room, the private receiver, the type and the time. The system messages are saved as JSON with their translation key and values.
  • Chat Message Types - the types and their tabs: Show Tab gives the type its own tab, and Also Show In Type shows its messages in the tab of another type too (in the sample data every type is also shown in the general message tab).
Admin Panel - Chat messages list Admin Panel - Chat Message Types list

The message types IDs are used by the code (1 message, 2 joined, 3 system, 4 private, 5 damage, 6 reward, 7 skill, 8 teams, 9 global, 10 error), change their tabs but do not change the IDs. See Chat Entity and Chat Message Types Entity.

Configuration reference

Server config (Settings > Config, scope server):

  • chat/messages/broadcast_join and chat/messages/broadcast_leave - show when a player joins or leaves.
  • chat/messages/global_enabled - allow the global messages.
  • chat/messages/global_allowed_roles - comma separated role IDs that can send global messages. The sample data has 1,9000: the regular players (role 1) can send them, add the admin role (99 by default) to allow the administrators too.
  • chat/messages/cooldownMs - minimum milliseconds between two messages of the same player (not installed, 1000 by default).

Client config (scope client):

  • chat/messages/characterLimit (100) and chat/messages/characterLimitOverhead (30) - maximum length of the messages and of the text shown over the player head.
  • ui/chat/enabled, ui/chat/defaultOpen, ui/chat/showTabs and ui/chat/notificationBalloon (the red mark on the chat icon for new messages), with the x, y, responsiveX and responsiveY position.
  • ui/chat/damageMessages, ui/chat/dodgeMessages and ui/chat/effectMessages - show the battle messages.
  • ui/chat/overheadChat/enabled, ui/chat/overheadChat/isTyping (shows that the player is writing) and ui/chat/overheadChat/closeChatBoxAfterSend.
  • ui/chat/overheadText/* - the font, colors, shadow, offset and timeOut (5000 milliseconds) of the text over the player head.

The tab names and the system texts are the chat client translations (lib/chat/client/snippets/en_US.js), for example chat.tabs.message "General" and chat.joinedRoom "%playerName has joined %roomName".

Code integration (advanced)

  • Server: ChatPlugin (lib/chat/server/plugin.js) adds the global chat room (RoomChat, used by the private and global messages) and the chat message action of every game room (ChatMessageActions, the room messages), and listens to the skills events for the battle messages.
  • ChatManager (lib/chat/server/manager.js) saves the messages and applies the cooldown, Cleaner trims them to the character limit and MessagesGuard drops the empty ones.
  • Client: ChatUi (lib/chat/client/chat-ui.js) sends the messages, renders the tabs from the message types and shows the overhead text.
  • Other features send chat messages with MessageFactory.create(type, message, data, from) (lib/chat/message-factory.js) and save them with ChatManager.saveMessage(), as the teams feature does.
Go Up