Simple Server-Controlled Chat

There are times when you even want your in-game chat to be controlled by the server, for example to either restrict the use of bad words, prevent spamming, or both.


On the player, attach a PlayerChatController which deals with input from the player and sends it to the server. We are using DF-GUI* for our GUI, hence the reference to dfTextbox, but the principles are the same regardless of which GUI-system you use;

*DF-GUI is no longer maintained, so please don't take this as a recommendation to use that GUI solution.


This controller is attached to the player's user interface and takes care of displaying the chat messages, scrolling them, removing the oldest ones etc. It also handles the chat-events;

Two events for the same task?

You might notice that there are two events doing basically the same thing here; just sending a chat message around. You are free to use only one event, where the clients sends the event only to the server (as in the code above) and then the same event to send to all the clients (or to everyone, including the server, as in the code above.)

It's all up to you.

 To Document Top