getDistanceBetweenCoords
GET_DISTANCE_BETWEEN_COORDS0xF1B760881820C952The GTA V native GET_DISTANCE_BETWEEN_COORDS of the MISC namespace, as LS:MP client scripts call it: the global function getDistanceBetweenCoords, in JavaScript and in Lua.
getDistanceBetweenCoords(
x1: number,
y1: number,
z1: number,
x2: number,
y2: number,
z2: number,
useZ: boolean
): numbergetDistanceBetweenCoords(
x1: number,
y1: number,
z1: number,
x2: number,
y2: number,
z2: number,
useZ: boolean
): numberUsage
JavaScript
const value = getDistanceBetweenCoords(x1, y1, z1, x2, y2, z2, useZ);Lua
local value = getDistanceBetweenCoords(x1, y1, z1, x2, y2, z2, useZ)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 = getDistanceBetweenCoords(pos1, pos2, useZ);Lua · with vectors
local value = getDistanceBetweenCoords(pos1, pos2, useZ)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 |
useZ | 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 the distance between two three-dimensional points, optionally ignoring the Z values.
If useZ is false, only the 2D plane (X-Y) will be considered for calculating the distance.
Consider using this faster native instead: vdist - DVIST always takes in consideration the 3D coordinates.
Reference
- Namespace
- Misc MISC
- In the game
float GET_DISTANCE_BETWEEN_COORDS(float x1, float y1, float z1, float x2, float y2, float z2, BOOL useZ)- Hash
0xF1B760881820C952