GetDistanceBetweenPoints2D: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 4: Line 4:


==Syntax==
==Syntax==
float [[getDistanceBetweenPoints2D]] ( float x1, float y1, float x2, float y2 )
<syntaxhighlight lang="lua">getDistanceBetweenPoints2D ( x1, y1, x2, y2 )</syntaxhighlight>


===Required Arguments===
===Required Arguments===
Line 14: Line 14:


==Example==
==Example==
vehiclex, vehicley, vehiclez = [[getVehiclePosition]] ( vehicle )
<syntaxhighlight lang="lua">vehiclex, vehicley, vehiclez = getVehiclePosition ( vehicle )
vehicle2x, vehicle2y, vehicle2z = [[getVehiclePosition]] ( vehicle2 )
vehicle2x, vehicle2y, vehicle2z = getVehiclePosition ( vehicle2 )
[[serverChat]] ( "The map distance between vehicle and vehicl2 is ", [[getDistanceBetweenPoints2D]] ( vehiclex, vehicley, vehicle2x, vehicle2y ) )
serverChat ( "The map distance between vehicle and vehicl2 is ", getDistanceBetweenPoints2D ( vehiclex, vehicley, vehicle2x, vehicle2y ) )</syntaxhighlight>

Revision as of 03:32, 18 May 2006

Description

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

Syntax

getDistanceBetweenPoints2D ( x1, y1, x2, y2 )

Required Arguments

  • x1: The X position of the first point
  • y1: The Y position of the first point
  • x2: The X position of the second point
  • y2: The Y position of the second point

Example

vehiclex, vehicley, vehiclez = getVehiclePosition ( vehicle )
vehicle2x, vehicle2y, vehicle2z = getVehiclePosition ( vehicle2 )
serverChat ( "The map distance between vehicle and vehicl2 is ", getDistanceBetweenPoints2D ( vehiclex, vehicley, vehicle2x, vehicle2y ) )