RedM Natives

_IS_POSITION_VALID_FOR_TRAIN

Returns whether the specified train config can be spawned at the given coordinates.

Hash0xF05DFAF1ADFEF2CD
Runtime nameIsPositionValidForTrain
NamespaceVEHICLE
SideClient
NameCommunity guess
Docs
Since build1207
Also known as_IS_SPAWN_POSITION_VALID_FOR_TRAIN

Signature

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

Parameters

NameTypeDescription
trainConfigHash—
xfloat—
yfloat—
zfloat—
directionBOOL—
p5BOOL—

Returns BOOL

Description

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.

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
local retval = IsPositionValidForTrain(trainConfig, x, y, z, direction, p5)

-- always works, by hash
local retval = Citizen.InvokeNative(0xF05DFAF1ADFEF2CD, trainConfig, x, y, z, direction, p5, Citizen.ReturnResultAnyway())
JavaScript and C#
JavaScript
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#
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

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