getDistanceBetweenPoints2D | Multi Theft Auto: Wiki Skip to content

getDistanceBetweenPoints2D

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function returns the distance between two 2 dimensional points using the pythagorean theorem.

Note

This function is equivalent to the Vector2 class getLength method when used with a vector that holds the direction and distance between two points. In other words, it produces exactly the same result as substracting the points' coordinates and getting the length of the result vector.

Syntax

getDistanceBetweenPoints2D ( )

Code Examples

server

This example gets the distance between two vehicles, stored in variablesvehicle1andvehicle2.

vehicle1x, vehicle1y, vehicle1z = getElementPosition ( vehicle1 )
vehicle2x, vehicle2y, vehicle2z = getElementPosition ( vehicle2 )
outputChatBox ( "The map distance between vehicle1 and vehicle2 is ", getDistanceBetweenPoints2D ( vehicle1x, vehicle1y, vehicle2x, vehicle2y ) )