Convars
Server settings from server.cfg (set, setr, sets) that scripts can read.
GetConvar
Section titled “GetConvar”GetConvar(varName, default) --> stringRead a convar as text. Server and client.
| Parameter | Type | Description |
|---|---|---|
varName |
string |
Name, for example “sv_hostname”. |
default |
string |
Returned if the convar is not set. |
Returns
string: The value or the default.
local locale = GetConvar('myres_locale', 'en')Compared to FiveM: Same as in FiveM. On the client only replicated convars (setr) are visible. Protected convars (for example the server key) always return the default.
GetConvarInt
Section titled “GetConvarInt”GetConvarInt(varName, default) --> integerRead a convar as a whole number. Server and client.
| Parameter | Type | Description |
|---|---|---|
varName |
string |
Name. |
default |
integer |
Returned if the convar is not set or not a number. |
Returns
integer: The value or the default.
local slots = GetConvarInt('sv_maxclients', 64)Compared to FiveM: Same as in FiveM.
GetConvarFloat
Section titled “GetConvarFloat”GetConvarFloat(varName, default) --> numberRead a convar as a number with decimals. Server and client.
| Parameter | Type | Description |
|---|---|---|
varName |
string |
Name. |
default |
number |
Returned if the convar is not set or not a number. |
Returns
number: The value or the default.
local rate = GetConvarFloat('myres_tax', 0.19)Compared to FiveM: Same as in FiveM.
GetConvarBool
Section titled “GetConvarBool”GetConvarBool(varName, default) --> booleanRead a convar as true or false. Server and client.
| Parameter | Type | Description |
|---|---|---|
varName |
string |
Name. |
default |
boolean |
Returned if the convar is not set or not a yes/no value. |
Returns
boolean: true for true, 1, yes, on; false for false, 0, no, off; otherwise the default.
if GetConvarBool('myres_debug', false) then print('debug on') endCompared to FiveM: Same as in FiveM.
SetConvar
Section titled “SetConvar”SetConvar(varName, value)Set a convar on the server. Server only.
| Parameter | Type | Description |
|---|---|---|
varName |
string |
Name. |
value |
string |
New value. |
SetConvar('myres_mode', 'event')Compared to FiveM: Same as in FiveM. Protected convars cannot be changed.
SetConvarReplicated
Section titled “SetConvarReplicated”SetConvarReplicated(varName, value)Set a convar that clients can read too. Server only.
| Parameter | Type | Description |
|---|---|---|
varName |
string |
Name. |
value |
string |
New value. |
SetConvarReplicated('myres_theme', 'dark')Compared to FiveM: Same as in FiveM.
SetConvarServerInfo
Section titled “SetConvarServerInfo”SetConvarServerInfo(varName, value)Set a convar that is shown in the server list. Server only.
| Parameter | Type | Description |
|---|---|---|
varName |
string |
Name. |
value |
string |
New value. |
SetConvarServerInfo('tags', 'roleplay,economy')Compared to FiveM: Same as in FiveM.