_IS_POSITION_VALID_FOR_TRAIN
Returns whether the specified train config can be spawned at the given coordinates.
Hash
0xF05DFAF1ADFEF2CDRuntime name
IsPositionValidForTrainNamespaceVEHICLE
SideClient
NameCommunity guess
Docs
Since build1207
Also known as
_IS_SPAWN_POSITION_VALID_FOR_TRAINSignature
BOOL _IS_POSITION_VALID_FOR_TRAIN(Hash trainConfig, float x, float y, float z, BOOL direction, BOOL p5);Parameters
| Name | Type | Description |
|---|---|---|
trainConfig | Hash | — |
x | float | — |
y | float | — |
z | float | — |
direction | BOOL | — |
p5 | BOOL | — |
Returns BOOL
Description
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.
Return true if the specified train can be spawned at the location (automatically snap to the nearest track from coords) with the direction.
Usage
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#
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());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.InvokeNativeneeds the number — passjoaat("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. Write10.0orvalue + 0.0. The generated JS wrappers add0.0000001to 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
InvokeNativewith the hash — it always works.
Sources
alloc8or RDR3 NativeDB · VORPCORE RDR3natives
Something wrong or missing? Contribute a verified note — corrections ship through pull requests.