Pool::atHandle

From RAGE Multiplayer Wiki
Revision as of 10:46, 4 January 2021 by Update450 (talk | contribs) (Created page with "This function is used to return an element from a pool at an entity handle. ==Syntax== <pre> Entity pool.atHandle(Number handle) </pre> ===Required Arguments=== *'''handle:'...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function is used to return an element from a pool at an entity handle.

Syntax

Entity pool.atHandle(Number handle)

Required Arguments

  • handle: You can get that for example using entity.handle function.

Returns

  • Entity
  • Note: If entity with selected handle does not exist, it will return undefined.

Example

This example will return a player by handle and output his name on the chat.

Client-Side
const player = mp.players.atHandle(mp.players.at(0).handle); // get handle of player with id 0
if (player) {
	mp.gui.chat.push(`Player with handle: ${localPlayerHandle} is named ${player.name}.`);
} else {
	mp.gui.chat.push(`Player with handle: ${localPlayerHandle} does not exist.`);
}

See Also