Skip to Content
ReferenceConsole Variables (Convars)

Console Variables (Convars)

Console Variables (Convars) are used to configure your FiveM server. They are typically defined in your server.cfg file but can also be set or read via scripts.

Setting Convars

In your server.cfg, you use set, sets, or standard command syntax.

  • set [name] [value]: Sets a variable that can be read by scripts.
  • sets [name] [value]: Sets a variable that is visible in the Server List UI (metadata).
  • [name] [value]: Standard internal convars (like sv_maxClients).
# Standard Internal Convar sv_maxclients 48 # Script Convar (Available to resources) set mysql_connection_string "server=127.0.0.1;database=fivem;userid=root;" # Server List Metadata sets tags "roleplay, police, ems" sets locale "en-US"

Reading Convars in Scripts

You can access these variables in your code to make your resources dynamic.

Lua

-- Get a string value (defaulting to "default_value" if not found) local dbString = GetConvar("mysql_connection_string", "default_value") -- Get an integer local maxPlayers = GetConvarInt("sv_maxclients", 48)

JavaScript

const dbString = GetConvar("mysql_connection_string", "default_value"); const maxPlayers = GetConvarInt("sv_maxclients", 48);

Standard Server Convars

These are built-in variables that control the core server behavior.

Networking & Connectivity

ConvarDescriptionExample
sv_maxclientsMaximum number of players allowed.sv_maxclients 48
sv_licenseKeyYour license key from keymaster.fivem.net .sv_licenseKey "cfxk_..."
endpoint_add_tcpTCP port binding (usually 30120).endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udpUDP port binding (usually 30120).endpoint_add_udp "0.0.0.0:30120"
onesyncEnables OneSync (Required for >48 players).onesync on

Server Details (Browser Visibility)

ConvarDescriptionExample
sv_hostnameThe display name of your server.sv_hostname "My RP Server"
sv_projectNameProject name (appears in list).sv_projectName "MyProject"
sv_projectDescProject description.sv_projectDesc "A cool server"
load_server_icon96x96 PNG icon for the server list.load_server_icon "myLogo.png"
sv_master1Set to empty string "" to hide from master list.sv_master1 ""

Game Configuration

ConvarDescriptionExample
sv_enforceGameBuildForces a specific GTA V DLC build (e.g., 3323).sv_enforceGameBuild 3323
sv_scriptHookAllowedAllows client-side trainers (Lambda, etc.). 0 = Disable.sv_scriptHookAllowed 0

Resource Management

ConvarDescriptionExample
ensure [resource]Starts a resource if not running, restarts if it is.ensure qb-core
start [resource]Starts a resource.start map-assets
stop [resource]Stops a resource.stop bad-script

Custom Convars

You can create your own convars for your scripts. This is great for configuration without editing code.

In server.cfg:

set myScript_difficulty "hard" set myScript_rewardMultiplier 2

In server.lua:

local difficulty = GetConvar("myScript_difficulty", "easy") local multiplier = GetConvarInt("myScript_rewardMultiplier", 1) if difficulty == "hard" then print("Hard mode enabled!") end

Security Note

Never put sensitive data (passwords, API keys) in sets command, as these are broadcast to the public server list API. Use set for internal configurations.

Last updated on