Knowledge from the fieldRedM

GetConvar always returns a string — `if GetConvar(x)` is truthy even for "false"

learning:76

GetConvar always returns a string — if GetConvar(x) is truthy even for "false"

Context

GET_CONVAR (0x6CCD2564) returns a char*. There is no implicit boolean/number coercion, so if GetConvar('x') then is true for every value — including the literal string "false" — because a non-empty string is truthy in Lua.

The fix

-- WRONG: always truthy
if GetConvar("my_flag", "false") then ... end
-- RIGHT: explicit string compare, or use typed variants
if GetConvar("my_flag", "false") == "true" then ... end
local n = GetConvarInt("my_int", 0)
local b = GetConvarBool("my_bool", false)

jo_libs reads a force-framework override as a string and compares against "false":

local v = GetConvar("jo_libs:framework", "false")
if v ~= "false" then return v end

Trap

The default-value (2nd) arg is also a string. Treating the return as a bool is a classic footgun.

Verified

framework-bridge/shared.lua:104.


Tags: cfx, getconvar, convar, string-return, truthiness, default-arg
Category: natives
Source: jo_libs-fleet
Created: 2026-05-31T09:43:50.562Z

Back to documentation