Entity::dist: Difference between revisions
(Created page with "Function that gets the distance between two entities. ==Parameters== * '''position''': {{RageType|Vector3}} ==Syntax== {{Shared}} <syntaxhighlight lang="javascript"> entity.d...") |
No edit summary |
||
| (5 intermediate revisions by 5 users not shown) | |||
| Line 1: | Line 1: | ||
{{ServersideJsFunction}} | |||
Gets the distance between two entities | |||
{{JSContainer| | |||
==Syntax== | ==Syntax== | ||
{{ | <pre>entity.dist(position)</pre> | ||
< | |||
=== Required Arguments === | |||
</ | *'''position:''' {{RageType|Vector3}} | ||
==Example== | |||
Gets the distance between a player and a vehicle | |||
{{ServersideCode| | |||
<pre> | |||
let distVeh = mp.vehicles.new(mp.joaat('turismor'), new mp.Vector3(-423.88, 1128.86, 326)); | |||
mp.events.addCommand('dist', (player) => { | |||
let dist = player.dist(distVeh.position); | |||
player.outputChatBox(`Distance: ${dist}`) | |||
}); | |||
</pre> | |||
}} | |||
}} | |||
==See also== | |||
{{Entity_definition}} | |||
[[Category:Entity API]] | |||
[[Category:Server-side Function]] | |||
Latest revision as of 12:25, 2 December 2019
Server-Side Function
Gets the distance between two entities
JavaScript Syntax
Syntax
entity.dist(position)
Required Arguments
- position: Vector3
Example
Gets the distance between a player and a vehicle
Server-Side
let distVeh = mp.vehicles.new(mp.joaat('turismor'), new mp.Vector3(-423.88, 1128.86, 326));
mp.events.addCommand('dist', (player) => {
let dist = player.dist(distVeh.position);
player.outputChatBox(`Distance: ${dist}`)
});