menu_bookDocumentation
Platform Chat: Built-in Text Chat with IChatEvent Filtering
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
| Property | Type | Description |
|---|---|---|
| Message | string | Mutable message text |
| Sender | Connection | Who sent it (null for system messages) |
| Suppress | bool | Set true to prevent delivery |
| RecipientFilter | Func<Connection, bool> | Per-connection visibility (host only) |
Was this helpful?