MiscClient

getRatioOfClosestPointOnLine

GET_RATIO_OF_CLOSEST_POINT_ON_LINE0x7F8F6405F4777AF6

The 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.

SignatureJavaScript
getRatioOfClosestPointOnLine(
  x1: number,
  y1: number,
  z1: number,
  x2: number,
  y2: number,
  z2: number,
  x3: number,
  y3: number,
  z3: number,
  clamp: boolean
): number
SignatureLua
getRatioOfClosestPointOnLine(
  x1: number,
  y1: number,
  z1: number,
  x2: number,
  y2: number,
  z2: number,
  x3: number,
  y3: number,
  z3: number,
  clamp: boolean
): number

Usage

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

ParameterTypeJavaScriptLua
x1floatnumbernumber
y1floatnumbernumber
z1floatnumbernumber
x2floatnumbernumber
y2floatnumbernumber
z2floatnumbernumber
x3floatnumbernumber
y3floatnumbernumber
z3floatnumbernumber
clampBOOLbooleanboolean

Returns

float JavaScript number, Lua number

Notes

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

Open in the interactive natives reference