s&box Console Commands: ConCmd & ConVar Explained

If you come from Garry’s Mod or Source 1, s&box’s console works differently — there’s no big server.cfg or fixed ConVar list. Instead, commands and variables are defined in C# with attributes, and you pass them on the launch line. Here’s how ConCmd and ConVar actually work in s&box.

The big difference from Source 1

s&box has a deliberately small configuration surface. There’s no server.cfg and no master ConVar list like the old engine. Anything you’d put in a config, you instead pass as a launch parameter when the server boots — those run as ConVars or ConCmds at startup.

ConCmd — console commands

A [ConCmd] attribute turns a C# method into a console command. The backend converts your string arguments to the method’s parameter types automatically:

[ConCmd( "greet" )]
public static void Greet( string name )
{
    Log.Info( $"Hello {name}" );
}

Add the ConVarFlags.Server flag to force a command to run on the server, and make the first parameter a Connection to know who ran it — essential for admin commands.

ConVar — console variables

A [ConVar] exposes a value you can read and change from the console. ConVars take flags that can be combined:

  • Saved — persists between sessions.
  • Replicated — synced from server to all clients.
  • UserInfo — sent from client to host in UserInfo.
  • GameSetting — exposed on the game’s creation screen.

Permissions — who can run what

Command and variable access is gated at the engine level with permission flags — Admin, Server, Replicated, and Cheat — plus Connection.HasPermission and the NetPermission enum. This is how you stop a random client from running server-only or cheat commands. Who counts as an admin is set in users/config.json — see our user permissions guide.

Generate them without the boilerplate

Writing ConCmd/ConVar attributes with the right flags by hand is error-prone. Our free ConCmd / ConVar generator builds the C# snippet with your chosen flags and parameters, and the admin commands guide covers running them on a live server. Hosting on XGamingServer s&box hosting gives you console and file access to test it all.

FAQ

Is there a server.cfg in s&box? No — pass settings as launch parameters; they execute as ConVars/ConCmds on boot.

How do I make a command server-only? Add ConVarFlags.Server to the [ConCmd] attribute.

How do I know who ran a command? Make the method’s first parameter a Connection.

Sources: s&box Docs — Console Variables.

Ready to play?

Run your own s&box server with XGamingServer

Spin up an always-on s&box server your friends can join in minutes — no port-forwarding, no tech headaches.

99.9%Uptime SLA
< 5 minInstant setup
24/7Human support
DDoSProtected
Instant setup Your server is live in minutes with a one-click control panel.
Mods & plugins Install mods, plugins and workshop content in a few clicks.
DDoS protected Enterprise DDoS mitigation keeps your server online 24/7.
Low-latency hardware Premium CPUs & NVMe SSDs for lag-free multiplayer.
Free backups Automatic backups so your world is never lost.
Real human support Gamers helping gamers — 24/7, no bots, no scripts.

Pick your s&box plan & play in minutes

See all plans
Starter $8.40/mo 4 GB RAM Renews $12/mo Buy now
Rookie $17.50/mo 8 GB RAM Renews $25/mo Buy now
Pro $24.50/mo 12 GB RAM Renews $35/mo Buy now