MiscClient1 output

findSpawnPointInDirection

FIND_SPAWN_POINT_IN_DIRECTION0x6874E2190B0C1972

The GTA V native FIND_SPAWN_POINT_IN_DIRECTION of the MISC namespace, as LS:MP client scripts call it: the global function findSpawnPointInDirection, in JavaScript and in Lua.

SignatureJavaScript
findSpawnPointInDirection(
  posX: number,
  posY: number,
  posZ: number,
  fwdVecX: number,
  fwdVecY: number,
  fwdVecZ: number,
  distance: number
): [ok: boolean, spawnPoint: { x: number, y: number, z: number }]
SignatureLua
findSpawnPointInDirection(
  posX: number,
  posY: number,
  posZ: number,
  fwdVecX: number,
  fwdVecY: number,
  fwdVecZ: number,
  distance: number
): boolean, Vector3

Usage

JavaScript
const [ok, spawnPoint] = findSpawnPointInDirection(
  posX, posY, posZ, fwdVecX, fwdVecY, fwdVecZ, distance
);
Lua
local ok, spawnPoint = findSpawnPointInDirection(
    posX, posY, posZ, fwdVecX, fwdVecY, fwdVecZ, distance
)

Three consecutive numbers can be given as one vector: { x, y, z } (or [x, y, z]) in JavaScript, a Vector3 in Lua.

JavaScript · with vectors
const [ok, spawnPoint] = findSpawnPointInDirection(pos, fwdVec, distance);
Lua · with vectors
local ok, spawnPoint = findSpawnPointInDirection(pos, fwdVec, distance)

Parameters

ParameterTypeJavaScriptLua
posXfloatnumbernumber
posYfloatnumbernumber
posZfloatnumbernumber
fwdVecXfloatnumbernumber
fwdVecYfloatnumbernumber
fwdVecZfloatnumbernumber
distancefloatnumbernumber

Returns

2 values, in this order: an array in JavaScript, multiple return values in Lua.

#ValueTypeJavaScriptLuaDescription
1okBOOLbooleanbooleanThe native’s own return value.
2spawnPointVector3{ x: number, y: number, z: number }Vector3output

Notes

From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.

Finds a position ahead of the player by predicting the players next actions.
The positions match path finding node positions.
When roads diverge, the position may rapidly change between two or more positions. This is due to the engine not being certain of which path the player will take.

Reference

Namespace
Misc MISC
In the game
BOOL FIND_SPAWN_POINT_IN_DIRECTION(float posX, float posY, float posZ, float fwdVecX, float fwdVecY, float fwdVecZ, float distance, Vector3* spawnPoint)
Hash
0x6874E2190B0C1972

Open in the interactive natives reference