# MISC::STRING_TO_INT

- **Hash:** `0xF2DD2298B3AF23E2`
- **Namespace:** MISC
- **Runtime name (Lua/JS):** `StringToInt`
- **Side:** client (game native)
- **Name status:** official
- **Documentation:** described
- **Since game build:** 1207
- **URL:** https://natives.borderlinerp.com/natives/MISC/STRING_TO_INT

## Signature

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

## Parameters

- `string` (`const char*`)
- `outInteger` (`int*`)

## 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

```lua
local retval, outInteger = StringToInt(string, outInteger)

-- always available, by hash
local retval, outInteger = Citizen.InvokeNative(0xF2DD2298B3AF23E2, string, Citizen.PointerValueIntInitialized(outInteger), Citizen.ReturnResultAnyway())
```

### JavaScript

```js
const [retval, outInteger] = StringToInt(string, outInteger);

// by hash
const [retval, outInteger] = Citizen.invokeNative('0xF2DD2298B3AF23E2', string, Citizen.pointerValueIntInitialized(outInteger), Citizen.returnResultAnyway());
```

### C#

```csharp
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.*
