Part 4 of 12: Game ConfigurationNext Part →
Game Configuration: Environment Variables
Game ConfigurationIntermediate

Game Configuration: Environment Variables

GameCP Team
2/21/2026
game-config, environment, variables, settings, configuration

This is Part 4 of the Game Configuration series. Environment variables are the primary way users configure their game servers — things like server name, max players, game mode, and map.

Environment Variables


What Are Environment Variables?

Environment variables are key-value pairs that get injected into the game server's container (or process) at startup. They serve two purposes:

  1. Server configuration — settings like SERVER_NAME, MAX_PLAYERS, GAME_MODE
  2. Variable substitution — referenced in command lines, scripts, and config files using ${VARIABLE_NAME} syntax

When a user creates a game server, they see these variables as editable fields in their server settings. Changing a variable and restarting applies the new value.


Environment References

The Environments selector lets you attach shared environment collections to your game config. Environments are reusable groups of variables that can be shared across multiple game configs.

For example, you might create an "API Keys" environment containing common credentials, then attach it to several game configs.

Select one or more environments to make their variables available. Servers created from this config will inherit those variables automatically.


Custom Environment Variables

Click Manage Variables to open the full variable editor. This is where you define game-specific variables that users can configure.

Manage Variables12 variables configuredEdit

Variable Properties

Each variable has:

PropertyDescription
KeyThe variable name (e.g., MAX_PLAYERS). Must be unique.
Default ValueThe initial value for new servers
LabelA human-readable name shown to users (e.g., "Max Players")
DescriptionHelp text explaining what the variable does
TypeThe input type: text, number, select, toggle, or hidden
RequiredWhether the variable must have a value
User EditableWhether server owners can change this from their server settings

grid

Variable Types

TypeRenders AsBest For
TextText inputServer name, passwords, custom strings
NumberNumber inputPlayer count, port numbers, tick rates
SelectDropdownGame mode, difficulty, map selection
ToggleSwitchEnable/disable features (PvP, whitelist, etc.)
HiddenNot shown to usersInternal values, system paths, credentials

Select Options

When using the Select type, you define a list of options with values and labels:

  • Value — the actual value passed to the server (e.g., survival)
  • Label — what the user sees in the dropdown (e.g., "Survival Mode")

Variable Ordering

Variables appear in the order you arrange them in the editor. Drag to reorder. Put the most important variables (server name, player count, game mode) at the top since users see them first.


How Variables Are Used

Variables flow through the entire system:

  1. Command Lines${MAX_PLAYERS} in arguments gets replaced with the actual value
  2. Config Files${MAX_PLAYERS} in config file templates gets substituted
  3. Docker — injected as environment variables into the container
  4. Scripts — available as environment variables in lifecycle scripts

Example Flow

If you define MAX_PLAYERS with a default of 20:

  • Command line argument: -maxplayers ${MAX_PLAYERS} becomes -maxplayers 20
  • Config file: max_players=${MAX_PLAYERS} becomes max_players=20
  • In Docker: the container sees MAX_PLAYERS=20 in its environment

When a user changes the value to 32 in their server settings, all of these update automatically on the next restart.


Tips

  • Use Hidden type for variables that users shouldn't touch (internal paths, system values)
  • Always provide sensible defaults so servers work out of the box
  • Include descriptions for every user-facing variable — users will thank you
  • Variable names are case-sensitive. Convention is UPPER_SNAKE_CASE
  • The variable editor supports drag-and-drop reordering — put the most common settings at the top