GET_CONVAR_FLOAT
This will have floating point inaccuracy.
Signature
float GET_CONVAR_FLOAT(char* varName, float defaultValue);Parameters
| Name | Type | Description |
|---|---|---|
varName | char* | The console variable to get |
defaultValue | float | The default value to set, if none are found. |
Returns float — Returns the value set in varName, or `default` if none are specified
Description
This will have floating point inaccuracy.
Usage
local retval = GetConvarFloat(varName, defaultValue)
-- always works, by hash
local retval = Citizen.InvokeNative(0x9e666d, varName, defaultValue, Citizen.ResultAsFloat())JavaScript and C#
const retval = GetConvarFloat(varName, defaultValue);
// by hash
const retval = Citizen.invokeNative('0x9e666d', varName, defaultValue + 0.0000001, Citizen.returnResultAnyway(), Citizen.resultAsFloat());float retval = Function.Call<float>((Hash)0x9e666d, varName, defaultValue);- Float parameters: Lua integers (
10, or whole numbers decoded from NUI/JSON) are sent as ints and read as garbage. Write10.0orvalue + 0.0. The generated JS wrappers add0.0000001to non-zero floats for the same reason.
Sources
Something wrong or missing? Contribute a verified note — corrections ship through pull requests.