Entity::dist: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
Line 1: Line 1:
Function that gets the distance between two entities.
{{ServersideJsFunction}}
==Parameters==
Gets the distance between two entities
* '''position''': {{RageType|Vector3}}


==Syntax==
==Syntax==
{{ServerSide}}
<pre>entity.dist(position)</pre>
 
=== Required Arguments ===
*'''position:''' {{RageType|Vector3}}
 
==Example==
Gets the distance between a player and a vehicle
{{ServersideCode|
<pre>
<pre>
entity.dist(entity2.position);
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>
</pre>
}}
==See also==
{{Entity_definition}}

Revision as of 01:20, 3 February 2019

Server-Side
Function

 JavaScript



Gets the distance between two entities

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}`)
});

See also