EntityClient

getNearestPlayerToEntity

GET_NEAREST_PLAYER_TO_ENTITY0x7196842CB375CDB3

The GTA V native GET_NEAREST_PLAYER_TO_ENTITY of the ENTITY namespace, as LS:MP client scripts call it: the global function getNearestPlayerToEntity, in JavaScript and in Lua.

SignatureJavaScript
getNearestPlayerToEntity(entity: Entity): Player
SignatureLua
getNearestPlayerToEntity(entity: Entity): Player

Usage

JavaScript
const player = getNearestPlayerToEntity(entity);
Lua
local player = getNearestPlayerToEntity(entity)

Parameters

ParameterTypeJavaScriptLua
entityEntitynumberinteger

Returns

Player JavaScript number, Lua integer

The game's own player index: a local slot, as playerId() returns it. Not an LS:MP playerId.

Reference

Namespace
Entity ENTITY
In the game
Player GET_NEAREST_PLAYER_TO_ENTITY(Entity entity)
Hash
0x7196842CB375CDB3

Open in the interactive natives reference