GetDistance3D: Difference between revisions

From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|GetDistance3D(x, y, z, x2, y2, z2)}} {{FuncParameters}} {{FuncParam|x|__EDIT_ME__}} {{FuncParam|y|..."
 
Wumbaloo (talk | contribs)
m Client sided script precision in example and math.floor added
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Info|Function|Server|1.0}}
{{Info|Function|Server & Client|1.0}}


{{FuncDescription|__EDIT_ME__}}
{{FuncDescription|Gets the distance in centimeters between 3 dimensional points.}}


{{FuncSyntax|GetDistance3D(x, y, z, x2, y2, z2)}}
{{FuncSyntax|GetDistance3D(x, y, z, x2, y2, z2)}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|x|__EDIT_ME__}}
{{FuncParam|x|x of the first point.}}
{{FuncParam|y|__EDIT_ME__}}
{{FuncParam|y|y of the first point.}}
{{FuncParam|z|__EDIT_ME__}}
{{FuncParam|z|z of the first point.}}
{{FuncParam|x2|__EDIT_ME__}}
{{FuncParam|x2|x of the second point.}}
{{FuncParam|y2|__EDIT_ME__}}
{{FuncParam|y2|y of the second point.}}
{{FuncParam|z2|__EDIT_ME__}}
{{FuncParam|z2|z of the second point.}}


{{FuncReturnValue|__EDIT_ME__}}
{{FuncReturnValue|The distance between the 2 points in centimeters.}}


== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua">
-- Client sided script
local x, y, z = GetPlayerLocation()
local distance = GetDistance3D(x, y, z, 2000, 13245, 1000)
 
AddPlayerChat("You're " .. math.floor(tonumber(distance) / 100) .. " meters from the position.")
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
__EDIT_ME__
* [[GetDistanceSquared3D]]
* [[GetDistance2D]]

Latest revision as of 20:04, 11 December 2019

GetDistance3D

Type: Function
Context: Server & Client
Introduced: v1.0

Description

Gets the distance in centimeters between 3 dimensional points.

Syntax

GetDistance3D(x, y, z, x2, y2, z2)

Parameters

  • x
    x of the first point.
  • y
    y of the first point.
  • z
    z of the first point.
  • x2
    x of the second point.
  • y2
    y of the second point.
  • z2
    z of the second point.

Return Value

  • The distance between the 2 points in centimeters.

Example

-- Client sided script
local x, y, z = GetPlayerLocation()
local distance = GetDistance3D(x, y, z, 2000, 13245, 1000)

AddPlayerChat("You're " .. math.floor(tonumber(distance) / 100) .. " meters from the position.")

See also