RedM Natives

STRING_TO_INT

Returns false if it's a null or empty string or if the string is too long.

Hash0xF2DD2298B3AF23E2
Runtime nameStringToInt
NamespaceMISC
SideClient
NameOfficial
Docs
Since build1207
GTA V hash0x5A5F40FE637EB584

Signature

BOOL STRING_TO_INT(const char* string, int* outInteger);

Parameters

NameTypeDescription
stringconst char*—
outIntegerint*—

Returns BOOL

Description

Returns false if it's a null or empty string or if the string is too long. outInteger will be set to -999 in that case.

Usage

Lua
local retval, outInteger = StringToInt(string, outInteger)

-- always works, by hash
local retval, outInteger = Citizen.InvokeNative(0xF2DD2298B3AF23E2, string, Citizen.PointerValueIntInitialized(outInteger), Citizen.ReturnResultAnyway())
JavaScript and C#
JavaScript
const [retval, outInteger] = StringToInt(string, outInteger);

// by hash
const [retval, outInteger] = Citizen.invokeNative('0xF2DD2298B3AF23E2', string, Citizen.pointerValueIntInitialized(outInteger), Citizen.returnResultAnyway());
C#
var outInteger = new OutputArgument();
bool retval = Function.Call<bool>((Hash)0xF2DD2298B3AF23E2, string, outInteger);
// outInteger.GetResult<int>()
  • The last argument is an in/out pointer: pass its initial value, and the updated value is returned after the result.

Sources

alloc8or RDR3 NativeDB

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