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.
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"You can access these variables in your code to make your resources dynamic.
-- 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)const dbString = GetConvar("mysql_connection_string", "default_value");
const maxPlayers = GetConvarInt("sv_maxclients", 48);These are built-in variables that control the core server behavior.
| Convar | Description | Example |
|---|---|---|
sv_maxclients | Maximum number of players allowed. | sv_maxclients 48 |
sv_licenseKey | Your license key from keymaster.fivem.net . | sv_licenseKey "cfxk_..." |
endpoint_add_tcp | TCP port binding (usually 30120). | endpoint_add_tcp "0.0.0.0:30120" |
endpoint_add_udp | UDP port binding (usually 30120). | endpoint_add_udp "0.0.0.0:30120" |
onesync | Enables OneSync (Required for >48 players). | onesync on |
| Convar | Description | Example |
|---|---|---|
sv_hostname | The display name of your server. | sv_hostname "My RP Server" |
sv_projectName | Project name (appears in list). | sv_projectName "MyProject" |
sv_projectDesc | Project description. | sv_projectDesc "A cool server" |
load_server_icon | 96x96 PNG icon for the server list. | load_server_icon "myLogo.png" |
sv_master1 | Set to empty string "" to hide from master list. | sv_master1 "" |
| Convar | Description | Example |
|---|---|---|
sv_enforceGameBuild | Forces a specific GTA V DLC build (e.g., 3323). | sv_enforceGameBuild 3323 |
sv_scriptHookAllowed | Allows client-side trainers (Lambda, etc.). 0 = Disable. | sv_scriptHookAllowed 0 |
| Convar | Description | Example |
|---|---|---|
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 |
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 2In server.lua:
local difficulty = GetConvar("myScript_difficulty", "easy")
local multiplier = GetConvarInt("myScript_rewardMultiplier", 1)
if difficulty == "hard" then
print("Hard mode enabled!")
endNever put sensitive data (passwords, API keys) in sets command, as these are broadcast to the public server list API. Use set for internal configurations.