FiveM Docs / Native Reference
API Set:
  • all
  • server
  • client
Language:
  • raw
  • lua
  • c#
  • js
Namespace: SYSTEMAPI set: clientGame: gta5editImprove

VDIST

0x2A488C176D52CCA5
0x3C08ECB7
// Vdist
float VDIST(float x1, float y1, float z1, float x2, float y2, float z2);
Parameters:
  • x1:

    X coordinate of the first point.

  • y1:

    Y coordinate of the first point.

  • z1:

    Z coordinate of the first point. Represents the height or elevation at the first point.

  • x2:

    X coordinate of the second point.

  • y2:

    Y coordinate of the second point.

  • z2:

    Z coordinate of the second point. Represents the height or elevation at the second point.

Returns:

Returns the distance as a float between the two points (x1, y1, z1) and (x2, y2, z2) in the game world.

Calculates the distance between two points in 3D space. For performance reasons, consider using direct mathematical calculations for distance, as they can be more efficient than calling this native function.

NativeDB Introduced: v323

Examples:

  • Lua
  • javascript
  • C#
-- Define a set of coordinates
local coords = vector3(145.0, 200.0, 1000.0)

-- Get the player's current ped
local playerPed = PlayerPedId()

-- Get the player's current coordinates
local coordsPlayer = GetEntityCoords(playerPed, false)

-- Calculate the distance between the player and the coordinates
local distance = Vdist(coordsPlayer.x, coordsPlayer.y, coordsPlayer.z, coords.x, coords.y, coords.z)

if (distance < 10.0) then
    print("You are close to the coordinates")
else
    print("You are far from the coordinates")
end
Privacy
•
Cookie Policy
•
Cookie Settings
0xF8155A7F03DDFC8E(Any p0)
0xFB199266061F820A()
Namespace: SYSTEM
CEIL(float value)
COS(float value)
FLOOR(float value)
_LOG10(float value)
POW(float base, float exponent)
ROUND(float value)
_SET_THREAD_PRIORITY(int priority)
SETTIMERA(int value)
SETTIMERB(int value)
SHIFT_LEFT(int value, int bitShift)
SHIFT_RIGHT(int value, int bitShift)
SIN(float value)
SQRT(float value)
START_NEW_SCRIPT(char* scriptName, int stackSize)
START_NEW_SCRIPT_WITH_ARGS(char* scriptName, Any* args, int argCount, int stackSize)
START_NEW_SCRIPT_WITH_NAME_HASH(Hash scriptHash, int stackSize)
START_NEW_SCRIPT_WITH_NAME_HASH_AND_ARGS(Hash scriptHash, Any* args, int argCount, int stackSize)
TIMERA()
TIMERB()
TIMESTEP()
TO_FLOAT(int value)
VDIST(float x1, float y1, float z1, float x2, float y2, float z2)
VDIST2(float x1, float y1, float z1, float x2, float y2, float z2)
VMAG(float x, float y, float z)
VMAG2(float x, float y, float z)
WAIT(int ms)
Namespace: TASK
ADD_COVER_BLOCKING_AREA(float playerX, float playerY, float playerZ, float radiusX, float radiusY, float radiusZ, BOOL p6, BOOL p7, BOOL p8, BOOL p9)
ADD_COVER_POINT(float p0, float p1, float p2, float p3, Any p4, Any p5, Any p6, BOOL p7)
ADD_PATROL_ROUTE_LINK(int id1, int id2)
ADD_PATROL_ROUTE_NODE(int id, char* guardScenario, float x1, float y1, float z1, float x2, float y2, float z2, int waitTime)
ADD_VEHICLE_SUBTASK_ATTACK_COORD(Ped ped, float x, float y, float z)