menu_bookDocumentation

Platform Chat: Built-in Text Chat with IChatEvent Filtering

calendar_today May 20, 2026 schedule ~1 min read person PatrickJr verified 50

s&box includes a built-in platform chat system for multiplayer games. Messages are routed through the host, validated, filtered via Steam's text filter, and displayed in a standard overlay UI — no game code required.

Configuration (Project Settings > Platform)

  • Chat Enabled — toggle the system on/off
  • Show Chat UI — hide built-in overlay while still processing messages (for custom UIs)
  • Max Message Length — cap at up to 256 characters

Sending Messages

CSHARP
// Send to all players (routed through host)
Chat.Say( "Hello everyone!" );

// Local-only notification (not networked)
Chat.AddText( $"{player.Name} joined the game" );

Messages are automatically sanitized, rate-limited, and passed through Steam's text filter. Blocked users are filtered on the receiving end.

Intercepting Messages with IChatEvent

Implement IChatEvent on a Component to modify, suppress, or filter messages:

CSHARP
public class TeamChat : Component, IChatEvent
{
    public void OnChatMessage( ChatMessageEvent e )
    {
        if ( !e.Message.StartsWith( "/team" ) ) return;

        e.Message = e.Message["/team ".Length..];

        // Only deliver to same team
        var senderTeam = GetTeam( e.Sender );
        e.RecipientFilter = connection => GetTeam( connection ) == senderTeam;
    }
}

ChatMessageEvent Properties

PropertyTypeDescription
MessagestringMutable message text
SenderConnectionWho sent it (null for system messages)
SuppressboolSet true to prevent delivery
RecipientFilterFunc<Connection, bool>Per-connection visibility (host only)
The event fires on the host (before broadcast) and on receiving clients (before display).
Was this helpful?