Pular para o conteúdo
server.cfg explained line by line

server.cfg explained line by line

What every common server.cfg line does: endpoints, hostname, tags, license key, slots, game build, OneSync, ensure order, convars, ACE permissions and splitting configs.

Por enquanto, esta documentação está em inglês.

Last updated

server.cfg is not a special format. It is a list of server console commands that FXServer runs from top to bottom when it starts, exactly as if you typed them into the console. That explains most of its behaviour: order matters, a typo is an “unknown command”, and anything you can type in the console you can put in the file.

Tip

Don’t want to write it by hand? The server.cfg Generator builds a complete file with hostname, slots, OneSync, endpoints, tags, resources and ACE permissions.

A complete example

This is a sensible config for a small public server without a framework. The sections below explain each part.

server.cfg
## Network
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"

## Server list info
sv_hostname "^2My Server ^7| Custom cars | Discord in desc"
sets sv_projectName "My Server"
sets sv_projectDesc "A small freeroam server with custom cars and friendly admins."
sets tags "freeroam, drift, cars"
sets locale "en-US"
load_server_icon myLogo.png
sets banner_detail "https://example.com/banner_detail.png"
sets banner_connecting "https://example.com/banner_connecting.png"

## Core settings
sv_licenseKey "cfxk_xxxxxxxxxxxxxxxxxxxx_xxxxxx"
sv_maxclients 32
sv_enforceGameBuild 3751
set onesync on
sv_endpointPrivacy true
sv_scriptHookAllowed 0
set steam_webApiKey "none"
set resources_useSystemChat true

## Resources (order matters)
ensure mapmanager
ensure chat
ensure spawnmanager
ensure basic-gamemode
ensure hardcap

ensure [local]

## Permissions
add_ace group.admin command allow
add_ace group.admin command.quit deny
add_principal identifier.fivem:123456 group.admin

Network: endpoints

server.cfg
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"

These bind the server to port 30120 on every network interface, TCP for HTTP (connection info, downloads) and UDP for game traffic. Both lines are needed. Change 30120 to run a second server on the same machine (for example 30121).

When txAdmin deploys a server, it writes these lines for you (the {{serverEndpoints}} placeholder in recipes), and the TXHOST_FXS_PORT variable can force a port. See Ports and networking.

Server list info

Line What it does
sv_hostname "..." The name in the server browser. Supports colour codes like ^1 red, ^2 green, ^7 white. Preview them with Draw Text Colors.
sets sv_projectName "..." Your community’s name. Shown in the server browser details. Required for proper listing.
sets sv_projectDesc "..." One sentence describing the server. Also required for proper listing.
sets tags "a, b, c" Comma separated tags for server browser search.
sets locale "en-US" The server’s main language. The default recipes use root-AQ, which means “not set”, so change it.
load_server_icon file.png Server icon, a 96x96 PNG in the server data folder.
sets banner_detail / sets banner_connecting Image URLs for the server detail page and the connecting screen.

set stores a convar, sets also publishes it in the server info (so the server browser can show it), and setr replicates it to clients so client scripts can read it with GetConvar. Use setr for things like voice_useNativeAudio that client code needs.

Core settings

sv_licenseKey

Your key from portal.cfx.re. Without a valid key the server will not start. Never paste it in screenshots or public repos. If it leaks, regenerate it on the Portal.

sv_maxclients

Maximum players, 1 to 2048. Up to 48 is free. Anything above 48 needs a Cfx.re Element Club tier (Argentum or higher) on the account that owns the key.

sv_enforceGameBuild

Forces clients to run a specific GTA V update, which unlocks that update’s vehicles, clothing, weapons and map changes. It can only be set at startup. Valid builds for FiveM include:

Build DLC
2699 The Criminal Enterprises
2802 Los Santos Drug Wars
2944 San Andreas Mercenaries
3095 The Chop Shop
3258 Bottom Dollar Bounties
3407 Agents of Sabotage
3570 Money Fronts
3751 A Safehouse in the Hills
3889 The Kortz Center Heist

Every build includes everything before it. The txAdmin default recipes currently set 3751. Pick the build your resources support: some older scripts and MLOs break on the newest build, and players have to download the matching game data the first time they join. You can check a build’s content in the Model & Hash Browser (vehicles, peds and weapons).

Note

FiveM for GTA V Enhanced only supports the latest game build, so this setting works differently there.

onesync

server.cfg
set onesync on

Turns on OneSync, the server side sync. Values are on, legacy (compatibility mode, not recommended) and off. Every current framework needs on, and you need it for more than 32 players, routing buckets, server side entity creation and state bags on entities. Use set onesync on in the cfg (or +set onesync on on the command line). txAdmin also exposes it in its settings.

Privacy and client mods

Line Meaning
sv_endpointPrivacy true Hides player IP addresses in the public player list output. Turn it on.
sv_scriptHookAllowed 0 Blocks clients with ScriptHookV (singleplayer mod menus). Default is off, keep it off.
sv_pureLevel 1 Blocks modified game files except audio and known graphics mods. 2 blocks all modified files. Leave it out to allow anything.
sv_entityLockdown strict Clients cannot create networked entities, only the server can. Great against cheaters, but many older scripts spawn things client side and will break. Test first.

Steam and chat

  • set steam_webApiKey "none" disables Steam identifiers. If your scripts need steam: identifiers, put a key from steamcommunity.com/dev/apikey.
  • set resources_useSystemChat true makes ensure chat use the chat resource built into the artifact instead of an old copy in your resources folder. The default txAdmin recipe sets this.

Resources: ensure, start and order

server.cfg
ensure mapmanager
ensure chat
ensure spawnmanager
ensure [local]
  • ensure name starts a resource, or restarts it if it is already running. It is the one you want in server.cfg.
  • start name starts it only if it is stopped. stop name stops it. restart name restarts a running one.
  • ensure [folder] starts every resource inside a bracketed category folder.
  • name is the folder name, not what the manifest says.

Order matters. Resources start in the order of the lines. Libraries and databases first, then the framework, then everything that depends on it:

server.cfg
ensure oxmysql
ensure ox_lib
ensure qbx_core        # or qb-core, es_extended
ensure ox_target
ensure ox_inventory
ensure [qbx]
ensure [standalone]
ensure [local]         # your own stuff last

If a resource lists dependencies in its manifest, FXServer starts those first anyway, but explicit order saves you confusing errors. More in Installing resources.

Splitting the config with exec

Big servers split their config. exec runs another file:

server.cfg
exec permissions.cfg
exec resources.cfg
exec @vMenu/config/permissions.cfg

Paths are relative to the server data folder, and @resource/path points into a resource. The Qbox recipe, for example, splits settings into permissions.cfg, ox.cfg, voice.cfg and misc.cfg.

A common trick is a secrets.cfg that holds the license key and database password and is not in git:

secrets.cfg
sv_licenseKey "cfxk_..."
set mysql_connection_string "mysql://fivem:password@localhost/fivem?charset=utf8mb4"
server.cfg
exec secrets.cfg

Database connection

Frameworks use oxmysql, which reads one convar:

server.cfg
set mysql_connection_string "mysql://user:password@localhost:3306/database?charset=utf8mb4"

The key value form "user=root;password=12345;host=localhost;port=3306;database=fivem" also works. Avoid special characters like @ : / ? # & = in the password. See Database setup.

Permissions (ACE)

server.cfg
add_ace group.admin command allow         # admins can run any command
add_ace group.admin command.quit deny     # except quit
add_principal identifier.fivem:123456 group.admin
add_principal identifier.discord:111111111111111111 group.admin
  • add_ace <principal> <object> <allow|deny> creates a rule.
  • add_principal <child> <parent> puts a player (or group) into a group.
  • Identifiers: identifier.fivem: (Cfx.re account ID), identifier.license:, identifier.discord:, identifier.steam:.

The txAdmin recipes add {{addPrincipalsMaster}}, which the deployer replaces with your own identifiers, so the master admin gets group.admin automatically. More in Security basics.

Listing, private servers and proxies

Line Use
sv_master1 "" Makes the server private: it will not appear in the server list. Leave it commented out (#sv_master1 "") for a public server.
sv_lan true LAN only server.
sv_listingIpOverride "1.2.3.4" Overrides the IP sent to the server list, for NAT setups.
sv_forceIndirectListing true Don’t advertise the server with its real IP.
sv_listingHostOverride "play.example.com" Overrides the host name sent to the list, for proxy setups.
sv_proxyIPRanges "a.b.c.d/24" IP ranges of your own proxies, so the real player IP is used.

These are advanced. See Ports and networking before touching them.

Things that don’t belong in server.cfg

  • rcon_password: RCON is off when unset, and txAdmin’s live console replaces it. Leave it unset.
  • Old lines copied from ancient tutorials, like start essentialmode, or a sv_master1 "" left over from a private test server.
  • Anything with your password if the file is shared or in git: move it to secrets.cfg.

After editing

Changes to server.cfg apply on the next server restart. In txAdmin you can edit the file under CFG Editor and restart from the dashboard. To pick up a new resource without a restart, type refresh then ensure name in the live console.