Pool::getClosest

From RAGE Multiplayer Wiki
Jump to navigation Jump to search

Server-Side
Function

Js.png JavaScript



Sorts the closest entities to a certain specified point in the entities pool.

JavaScript Syntax
Jslogo.png

Syntax

mp.Pool.getClosest(pos, limit)

Required Arguments

  • *pos: Array ([x, y, z])
  • limit: Int (Default is 1)

Example

Server-Side
let player = mp.players.getClosest([0,0,0]);
console.log(player.id);

let players = mp.players.getClosest([0,0,0], 2);
console.log(players[0].id);

let allPlayersSortedByDistanceToPoint = mp.players.getClosest([0,0,0], mp.players.length);


See Also