s&box Network Events Reference
Searchable cheatsheet for s&box's INetworkListener and INetworkSpawn — AcceptConnection, OnConnected, OnDisconnected, OnActive, OnBecameHost, OnNetworkSpawn — with copy-ready C# implementations and method signatures pulled from the live s&box C# API schema. Essential for first-time s&box dedicated server developers.
Called on the host when a client is fully connected and has completed the handshake. After this call they will close the loading screen and start playing. This is the right place to spawn the player object and assign ownership.
Most commonly the player-spawn hook. Always called after OnConnected.
[Property] public GameObject PlayerPrefab { get; set; }
[Property] public GameObject SpawnPoint { get; set; }
public void OnActive( Connection channel )
{
var player = PlayerPrefab.Clone( SpawnPoint.Transform.World );
// Optional: read a NameTag component if your prefab has one.
var nameTag = player.Components.Get<NameTagPanel>(
FindMode.EverythingInSelfAndDescendants );
if ( nameTag is not null )
{
nameTag.Name = channel.DisplayName;
}
// Spawn it on the network and assign the connection as the owner.
player.NetworkSpawn( channel );
}Called when this object is spawned on the network. The owner parameter is the Connection that owns the object (or null if there is no owner). Fires on every client (and the host). Useful for hooking up local state to a freshly-networked object — running effects, registering with managers, etc.
public void OnNetworkSpawn( Connection owner )
{
// Runs on every client + the host once this object goes networked.
Log.Info( $"{GameObject.Name} spawned on the network, owned by {owner?.DisplayName ?? "host"}." );
// e.g. start an effect, register with a manager, etc.
Components.Get<ParticleEffect>()?.Reset();
}s&box Network Events
Game logic in s&box reacts to network state by implementing one of two interfaces on a Component placed in the scene: Component.INetworkListener for connection events (OnConnected, OnDisconnected, OnActive) or Component.INetworkSpawn for the per-object spawn event (OnNetworkSpawn). The methods are optional — implement only the ones you care about.
OnConnected vs OnActive
The two are easy to confuse. OnConnectedfires the moment a client opens the connection — they haven't loaded the game yet, packages are still downloading, and they can't see anything. OnActive fires once the handshake is complete and the loading screen has closed; this is when you should spawn the player objectand assign ownership. Don't try to do that in OnConnected— the client isn't ready to receive it.
Full GameNetworkManager Example
using Sandbox;
// Implement INetworkListener on a Component placed in the scene to react to lobby events.
public sealed class GameNetworkManager : Component, Component.INetworkListener
{
[Property] public GameObject PlayerPrefab { get; set; }
[Property] public GameObject SpawnPoint { get; set; }
/// <summary>The client just opened a connection — handshake hasn't finished.</summary>
public void OnConnected( Connection connection )
{
Log.Info( $"{connection.DisplayName} connected — handshaking..." );
}
/// <summary>The client is fully in. Spawn their player here.</summary>
public void OnActive( Connection connection )
{
var player = PlayerPrefab.Clone( SpawnPoint.Transform.World );
player.NetworkSpawn( connection );
}
/// <summary>The client left for any reason. Clean up.</summary>
public void OnDisconnected( Connection connection )
{
Log.Info( $"{connection.DisplayName} left." );
}
}
// Implement INetworkSpawn on a Component to react to its own object being networked.
public sealed class FlashOnSpawn : Component, Component.INetworkSpawn
{
public void OnNetworkSpawn()
{
Log.Info( $"{GameObject.Name} just appeared on the network." );
}
}Place the GameNetworkManager component in your starting scene with PlayerPrefab and SpawnPoint wired up. New connections will auto-spawn a player on join and tear down on leave.
Related s&box Tools
- Lobby Config Builder — generate
Networking.CreateLobbycalls. - RPC Generator — generate
[Rpc.Broadcast]/Owner/Hostmethod skeletons. - Sync Properties Generator — wire up
[Sync]+[Change]properties.
s&box Network Events Reference — FAQ
Is this s&box Network Events Reference free to use?
Yes, the s&box Network Events Reference is 100% free — no signup required, no hidden fees, no downloads. Everything runs in your browser.
How accurate is the s&box Network Events Reference?
Values are pulled from the s&box game files and community-verified formulas. Results match what you see in-game, and we update the tool when the game gets major patches.
Can I host a s&box server with XGamingServer?
Yes. XGamingServer offers instant s&box server hosting with mod support, automatic backups, DDoS protection, and 24/7 support. All popular game settings are pre-configured.
Does the Network Events Reference work on mobile?
Yes, the Network Events Reference is fully responsive and works on desktop, tablet, and mobile browsers.
You might also need
Launch Command Builder
Build the exact sbox-server.exe launch command — +game (published or local .sbproj), +hostname, +port, +net_query_port, +net_game_server_token, optional map package. Validates branch (main/staging) requirements and outputs ready-to-run Run-Server.bat / run-server.sh.
SteamCMD Builder
Generate copy-paste SteamCMD install/update scripts for the s&box Dedicated Server (app 1892930). Main vs staging branch toggle, validate option, anonymous login, side-by-side Windows .bat and Linux .sh.
users/config.json Generator
Visual editor for the s&box dedicated server admin file — add multiple Steam accounts with their SteamID64, display name, and claims (kick, ban, restart, plus your own custom claims). Validates SteamID format and outputs paste-ready users/config.json.
Steam ID Resolver
Convert any Steam profile URL, vanity URL, SteamID2 (STEAM_0:0:...), or SteamID3 ([U:1:...]) into the SteamID64 format that users/config.json and most server tools require. All formats shown side-by-side with copy buttons.
s&box server admin docs
Read the full s&box server docs →
Step-by-step guides for installing mods, configuring your server, joining, troubleshooting, and admin commands.

Config Tool Built Into XGamingServer
Get managed s&box hosting with this tool in your panel — configure, deploy, and play in minutes. No file uploads needed.