RedM Natives

GET_CONVAR_INT

Can be used to get a console variable casted back to int (an integer value).

Hash0x935C0AB2
Runtime nameGetConvarInt
NamespaceCFX
SideClient + server
NameOfficial
Docs

Signature

int GET_CONVAR_INT(char* varName, int default_);

Parameters

NameTypeDescription
varNamechar*

The console variable to look up.

default_int

The default value to set if none is found (variable not set using SET_CONVAR, or not accessible).

Returns int — Returns the convar value if it can be found, otherwise it returns the assigned `default`.

Description

Cfx.re native reference

Can be used to get a console variable casted back to int (an integer value).

Usage

Lua
local retval = GetConvarInt(varName, default_)

-- always works, by hash
local retval = Citizen.InvokeNative(0x935c0ab2, varName, default_, Citizen.ResultAsInteger())
JavaScript and C#
JavaScript
const retval = GetConvarInt(varName, default_);

// by hash
const retval = Citizen.invokeNative('0x935c0ab2', varName, default_, Citizen.returnResultAnyway(), Citizen.resultAsInteger());
C#
int retval = Function.Call<int>((Hash)0x935c0ab2, varName, default_);

Examples

LUA · Cfx.re native reference
if GetConvarInt('remainingRounds', 0) < 900 then
    Citizen.Trace("Less than 900 rounds remaining...")
end

Sources

Cfx.re native reference

Something wrong or missing? Contribute a verified note — corrections ship through pull requests.