getRatioOfClosestPointOnLine
GET_RATIO_OF_CLOSEST_POINT_ON_LINE0x7F8F6405F4777AF6The GTA V native GET_RATIO_OF_CLOSEST_POINT_ON_LINE of the MISC namespace, as LS:MP client scripts call it: the global function getRatioOfClosestPointOnLine, in JavaScript and in Lua.
getRatioOfClosestPointOnLine(
x1: number,
y1: number,
z1: number,
x2: number,
y2: number,
z2: number,
x3: number,
y3: number,
z3: number,
clamp: boolean
): numbergetRatioOfClosestPointOnLine(
x1: number,
y1: number,
z1: number,
x2: number,
y2: number,
z2: number,
x3: number,
y3: number,
z3: number,
clamp: boolean
): numberUsage
JavaScript
const value = getRatioOfClosestPointOnLine(x1, y1, z1, x2, y2, z2, x3, y3, z3, clamp);Lua
local value = getRatioOfClosestPointOnLine(x1, y1, z1, x2, y2, z2, x3, y3, z3, clamp)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 value = getRatioOfClosestPointOnLine(pos1, pos2, pos3, clamp);Lua · with vectors
local value = getRatioOfClosestPointOnLine(pos1, pos2, pos3, clamp)Parameters
| Parameter | Type | JavaScript | Lua |
|---|---|---|---|
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 |
Returns
float JavaScript number, Lua numberNotes
From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.
returns a float between 0.0 and 1.0, clamp: sets whether the product should be clamped between the given coordinates
Reference
- Namespace
- Misc MISC
- In the game
float GET_RATIO_OF_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
0x7F8F6405F4777AF6- Formerly
_GET_PROGRESS_ALONG_LINE_BETWEEN_COORDS