Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/facepunch/sbox-public/llms.txt

Use this file to discover all available pages before exploring further.

The s&box networking API is split across three layers: the Networking static class for session management, the Rpc static class and its nested attributes for remote procedure calls, and the [Sync] attribute for automatic property synchronization. This page covers all three layers with their real signatures taken from source.
Networking.IsHost returns true even in a local single-player session. Use Networking.IsActive to check whether a real multiplayer session exists.

Networking static class

Session state

Networking.IsHost
bool
true if this peer is the host of the current session, or if no networked session exists (local play).
Networking.IsClient
bool
true if this peer is connected to a server and is not the host.
Networking.IsActive
bool
true when a NetworkSystem instance is active — i.e. a real multiplayer session exists.
Networking.IsConnecting
bool
true while the initial connection handshake is in progress.
Networking.MaxPlayers
int
The maximum number of players allowed in the current session. Set by the host via LobbyConfig.
Networking.ServerName
string
The display name of the server. Setting this on the host propagates the new name to all connected clients.
Networking.MapName
string
The name of the map currently in use on the server.
Networking.HostStats
HostStats
Live statistics from the host including bandwidth usage and frame rate. Returns default when not connected.

Lobby management

Networking.CreateLobby(LobbyConfig config)
void
Creates a Steam lobby using the provided configuration. Throws if called outside a game context or if the session is already active.
Networking.JoinBestLobby(string ident)
Task<bool>
Queries available lobbies for the given game ident and connects to the most-populated one. Returns true on success.
Networking.Connect(string target)
void
Connects to a server. target can be a Steam ID (as a ulong string), an IP address, or "local" for a local TCP connection.
Networking.Connect(ulong steamid)
void
Connects directly to a peer by Steam ID.
Networking.TryConnectSteamId(SteamId steamId, int retries)
Task<bool>
Attempts to connect to a Steam lobby or peer, retrying up to retries times.
Networking.Disconnect()
void
Disconnects from the current session and tears down the NetworkSystem.

Server data

Networking.SetData(string key, string value)
void
Sets a key/value pair on the server that other players can query when browsing lobbies. Keep keys and values short — Steam enforces a character limit on server tags.
Networking.GetData(string key, string defaultValue)
string
Gets a server data value set by SetData. Returns defaultValue if the key is not set.

RPC attributes

RPCs let you call a method on one peer from another. Decorate a method with one of the Rpc.* attributes — the engine code-generates the network dispatch automatically.

Rpc.Broadcast

[Rpc.Broadcast]
public void OnPlayerDied()
{
    // Called on every connected client including the host
}
[Rpc.Broadcast]
attribute
The method runs on all connected clients (and the host). Use for events that every client needs to react to — sound effects, score updates, particle spawns.

Rpc.Host

[Rpc.Host]
public void RequestPickup( GameObject item )
{
    // Only runs on the host — validate and process the request here
}
[Rpc.Host]
attribute
The method runs only on the host. Use this when a client needs to ask the host to perform an authoritative action (picking up an item, spending currency, validating a move).

Rpc.Owner

[Rpc.Owner]
public void OnTakeDamage( float amount )
{
    // Runs on the owner of this GameObject (or the host if unowned)
}
[Rpc.Owner]
attribute
The method runs on the owner of the GameObject, or on the host when the object is unowned. Use this to send authoritative state to the client who controls a particular object.

RPC context

Inside an RPC method you can inspect who invoked it:
Rpc.Caller
Connection
The Connection that triggered this RPC call. Read this inside an RPC method to identify the sender.
Rpc.CallerId
Guid
The Guid of the calling connection. Equivalent to Rpc.Caller.Id.
Rpc.Calling
bool
true when the current execution context is inside an RPC callback from a remote connection.

Filtering recipients

Use Rpc.FilterInclude or Rpc.FilterExclude to narrow the recipient set for any Rpc.Broadcast call within the scope:
// Send only to a specific connection
using ( Rpc.FilterInclude( targetConnection ) )
{
    SendSecretMessage( "only you can see this" );
}

// Send to everyone except one connection
using ( Rpc.FilterExclude( spectatorConnection ) )
{
    AnnounceRoundStart();
}
Rpc.FilterInclude(IEnumerable<Connection> connections)
IDisposable
Restricts RPC recipients to the provided connections for the duration of the using block.
Rpc.FilterInclude(Predicate<Connection> predicate)
IDisposable
Restricts RPC recipients to connections that satisfy the predicate.
Rpc.FilterInclude(Connection connection)
IDisposable
Restricts RPC recipients to a single connection.
Rpc.FilterExclude(IEnumerable<Connection> connections)
IDisposable
Excludes the provided connections from receiving the RPC.
Rpc.FilterExclude(Predicate<Connection> predicate)
IDisposable
Excludes connections that satisfy the predicate.
Rpc.FilterExclude(Connection connection)
IDisposable
Excludes a single connection from receiving the RPC.

[Sync] attribute

[Sync] marks a property on a networked component for automatic synchronization from the owner to all other clients. The engine intercepts the property setter and getter at compile time via code generation.
public class PlayerComponent : Component
{
    [Sync] public int Health { get; set; }

    [Sync( SyncFlags.Interpolate )] public Vector3 Velocity { get; set; }

    [Sync( SyncFlags.FromHost )] public string TeamName { get; set; }
}
[Sync]
attribute
Synchronizes the property from the owner to all other clients.

SyncFlags

SyncFlags.FromHost
flag
The host owns the value and propagates it to all clients. Use this for game-state properties that only the host should write, such as team assignments or round timers.Previously done with the now-obsolete [HostSync] attribute.
SyncFlags.Query
flag
Tells the network system to poll the property getter every tick rather than relying on the setter being called. Use this when the property value can change without an explicit setter call — for example a computed property.
SyncFlags.Interpolate
flag
Smoothly interpolates the value between network ticks on proxy clients. Supported types: float, double, Angles, Rotation, Transform, Vector3.

NetworkFlags

NetworkFlags is a flags enum that configures how the transform of a NetworkObject is synchronized. Set it on GameObject.Network.Flags.
FlagValueEffect
None0Default: all transform components are synchronized.
NoInterpolation1Disables network interpolation for this object. Transform changes snap immediately on proxy clients.
NoPositionSync2Position is not synchronized over the network.
NoRotationSync4Rotation is not synchronized over the network.
NoScaleSync8Scale is not synchronized over the network.
NoTransformSync14Combines NoPositionSync, NoRotationSync, and NoScaleSync. No transform data is sent.
// Sync only position — skip rotation and scale
GameObject.Network.Flags = NetworkFlags.NoRotationSync | NetworkFlags.NoScaleSync;

// Completely disable transform sync (e.g. a static prop)
GameObject.Network.Flags = NetworkFlags.NoTransformSync;

// Disable interpolation for a fast-moving projectile
GameObject.Network.Flags = NetworkFlags.NoInterpolation;
Only the host can change NetworkFlags after an object has been spawned on the network. Changes from clients are silently ignored.

Usage examples

// In your game component
Networking.CreateLobby( new LobbyConfig
{
    MaxPlayers = 16,
    Name = "My Server",
    Privacy = LobbyPrivacy.Public
} );

Networking overview

Host/client model, NetworkObject ownership, and lifecycle events.

Sync vars guide

Detailed walkthrough of [Sync], SyncFlags, and ownership-aware sync.

RPCs guide

Step-by-step guide to writing and calling RPCs safely.

Game class

Global session state and Game.ActiveScene.

Build docs developers (and LLMs) love