GetNearestEntity
The entity nearest to a player, of a kind, within a radius.
Horizontal distance, in the player’s own virtual world only.
Syntax
Section titled “Syntax”GetNearestEntity(pid, kind [, radius])| Parameter | Type | |
|---|---|---|
pid |
number | the player |
kind |
number | nil | an entity kind; nil = any |
radius |
number | metres; without it, any distance (optional) |
Returns
Section titled “Returns”number, number - the entity id and its distance in metres; nil when none
Example
Section titled “Example”-- /mount: the nearest horse within ten metreslocal horse = GetNearestEntity(pid, ENTITY_HORSE, 10)if horse then MountPlayer(pid, horse) else SendClientMessage(pid, COLOUR_RED, "No horse near you.") endSee also
Section titled “See also”GetEntities · GetEntityPos · the World entities group of the index
