s&box Network Events Reference
Searchable cheatsheet for s&box's INetworkListener and INetworkSpawn — OnConnected, OnDisconnected, OnActive, OnNetworkSpawn — with copy-ready C# implementations sourced from the official Facepunch docs. Essential for first-time s&box dedicated server developers.
Called on the host when a client has just connected to the server. They are about to start handshaking — they will load the game and download all required packages next. The player isn't fully in yet; don't spawn anything for them here.
Fires before the client has finished loading. Wait for OnActive before spawning the player.
public void OnConnected( Connection connection )
{
Log.Info( $"{connection.DisplayName} connected — handshaking..." );
}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 connection )
{
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 = connection.DisplayName;
}
// Spawn it on the network and assign the connection as the owner.
player.NetworkSpawn( connection );
}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.

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.