# VEHICLE::_IS_POSITION_VALID_FOR_TRAIN

- **Hash:** `0xF05DFAF1ADFEF2CD`
- **Namespace:** VEHICLE
- **Runtime name (Lua/JS):** `IsPositionValidForTrain`
- **Side:** client (game native)
- **Name status:** community guess (may change)
- **Documentation:** described
- **Since game build:** 1207
- **Other names:** `_IS_SPAWN_POSITION_VALID_FOR_TRAIN`
- **URL:** https://natives.borderlinerp.com/natives/VEHICLE/_IS_POSITION_VALID_FOR_TRAIN

## Signature

```c
BOOL _IS_POSITION_VALID_FOR_TRAIN(Hash trainConfig, float x, float y, float z, BOOL direction, BOOL p5);
```

## Parameters

- `trainConfig` (`Hash`)
- `x` (`float`)
- `y` (`float`)
- `z` (`float`)
- `direction` (`BOOL`)
- `p5` (`BOOL`)

## Returns

`BOOL`

## Description

*Source: alloc8or RDR3 NativeDB*

Returns whether the specified train config can be spawned at the given coordinates.
The engine snaps the coordinates to the nearest track and checks the requested direction, matching the direction parameter used by CREATE_MISSION_TRAIN.

*Source: VORPCORE RDR3natives*

Return true if the specified train can be spawned at the location (automatically snap to the nearest track from coords) with the direction.

## Usage

### Lua

```lua
local retval = IsPositionValidForTrain(trainConfig, x, y, z, direction, p5)

-- always available, by hash
local retval = Citizen.InvokeNative(0xF05DFAF1ADFEF2CD, trainConfig, x, y, z, direction, p5, Citizen.ReturnResultAnyway())
```

### JavaScript

```js
const retval = IsPositionValidForTrain(trainConfig, x, y, z, direction, p5);

// by hash
const retval = Citizen.invokeNative('0xF05DFAF1ADFEF2CD', trainConfig, x + 0.0000001, y + 0.0000001, z + 0.0000001, direction, p5, Citizen.returnResultAnyway());
```

### C#

```csharp
bool retval = Function.Call<bool>((Hash)0xF05DFAF1ADFEF2CD, trainConfig, x, y, z, direction, p5);
```

- Hash parameters: the named function also accepts a string and hashes it for you; `Citizen.InvokeNative` needs the number — pass `joaat("name")` or a backtick literal like `` `name` ``.
- Float parameters: Lua integers (`10`, or whole numbers decoded from NUI/JSON) are sent as ints and read as garbage. Write `10.0` or `value + 0.0`. The generated JS wrappers add `0.0000001` to non-zero floats for the same reason.
- The name is a community guess and may change. If the named call is missing in your client build, use `InvokeNative` with the hash — it always works.

*Sources: alloc8or RDR3 NativeDB, VORPCORE RDR3natives.*
