Pool::atHandle
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
- Functions
- Properties
- Arrays