Convars: server.cfg config you can read from Lua
A convar (configuration variable) is a key/value pair you set in server.cfg or at runtime, then read from Lua. Convars are how you externalize the things that change per server: a debug flag, a database name, a starting balance, an owner ID. You tune them without editing Lua and without rebuilding the resource. The catch that trips up everyone is replication: the prefix you use to declare a convar decides whether a client can ever read it. Get that wrong and your client silently reads the default forever. This lesson makes the difference visible.
Build it
Make the resource folder
Inside your server's resources folder, create this folder:
resources/qu_convars_server_cfg
Create the files
Create this exact file layout:
resources/qu_convars_server_cfg/
fxmanifest.lua
server.lua
client.lua
Write fxmanifest.lua
Open fxmanifest.lua and paste this:
fx_version 'cerulean'
game 'gta5'
server_script 'server.lua'
client_script 'client.lua'
Older tutorials add a lua54 'yes' line here. As of June 2025 that setting is deprecated and ignored: Lua 5.4 is now the only Lua runtime, so you leave it out.
Declare the convars in server.cfg
Open server.cfg and add these two lines above the line that ensures this resource. You will add the ensure line in Step 6.
set qu_convars_cash 750
setr qu_convars_debug true
The two prefixes are not interchangeable. set is server-only. setr is replicated, which means it is also sent to every client. You will see in a moment why the client half of this lesson reads the setr one and not the set one.
Write the lesson code
Open server.lua and paste this:
RegisterCommand('cashcfg', function()
local cash = GetConvarInt('qu_convars_cash', 500)
print('[qu_convars_server_cfg] server reads cash ' .. cash)
end, false)
Keep reading the full lesson
Sign in to start, then unlock every step of this lesson and the full FiveM School with a membership.
- How it works
- If something went wrong
- What you can do now
- Try it yourself
The remainder of ConVars and secrets is available to FiveM School members.