Pool::getClosest

From RAGE Multiplayer Wiki
Revision as of 12:37, 9 December 2019 by Unknown (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Server-Side
Function

 JavaScript



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

JavaScript Syntax

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