Pool::getClosest: Difference between revisions
No edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
{{ServersideJsFunction}} | {{ServersideJsFunction}} | ||
Sorts the closest entities to a certain specified point in the entities pool. | |||
{{JSContainer| | {{JSContainer| | ||
| Line 24: | Line 26: | ||
}} | }} | ||
}} | }} | ||
==See Also== | |||
{{EntityPool_function}} | |||
Latest revision as of 12:37, 9 December 2019
Server-Side Function
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
- Functions
- Properties
- Arrays