getClosestPointOnLine
GET_CLOSEST_POINT_ON_LINE0x21C235BC64831E5AThe GTA V native GET_CLOSEST_POINT_ON_LINE of the MISC namespace, as LS:MP client scripts call it: the global function getClosestPointOnLine, in JavaScript and in Lua.
getClosestPointOnLine(
x1: number,
y1: number,
z1: number,
x2: number,
y2: number,
z2: number,
x3: number,
y3: number,
z3: number,
clamp: boolean
): { x: number, y: number, z: number }getClosestPointOnLine(
x1: number,
y1: number,
z1: number,
x2: number,
y2: number,
z2: number,
x3: number,
y3: number,
z3: number,
clamp: boolean
): Vector3Usage
JavaScript
const { x, y, z } = getClosestPointOnLine(x1, y1, z1, x2, y2, z2, x3, y3, z3, clamp);Lua
local coords = getClosestPointOnLine(x1, y1, z1, x2, y2, z2, x3, y3, z3, clamp)
-- coords.x, coords.y, coords.zThree 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 coords = getClosestPointOnLine(pos1, pos2, pos3, clamp);Lua · with vectors
local coords = getClosestPointOnLine(pos1, pos2, pos3, clamp)Parameters
| Parameter | Type | JavaScript | Lua | Description |
|---|---|---|---|---|
x1 | float | number | number | |
y1 | float | number | number | |
z1 | float | number | number | |
x2 | float | number | number | |
y2 | float | number | number | |
z2 | float | number | number | |
x3 | float | number | number | |
y3 | float | number | number | |
z3 | float | number | number | |
clamp | BOOL | boolean | boolean | sets whether the product should be clamped between the given coordinates |
Returns
Vector3 JavaScript { x: number, y: number, z: number }, Lua Vector3A 3D vector. JavaScript gets a plain { x, y, z } object; Lua gets a real Vector3, with .x .y .z and arithmetic. As an argument, one vector fills three consecutive coordinates.
Reference
- Namespace
- Misc MISC
- In the game
Vector3 GET_CLOSEST_POINT_ON_LINE(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, BOOL clamp)- Hash
0x21C235BC64831E5A