Pool::atHandle: Difference between revisions
(Again improve, this time my mistake) |
(Improve again) |
||
| (One intermediate revision by the same user not shown) | |||
| Line 9: | Line 9: | ||
===Returns=== | ===Returns=== | ||
*{{RageType|Entity}} Entity with specified | *{{RageType|Entity}} Entity with specified handle, '''undefined''' if none exists. | ||
==Example== | ==Example== | ||
This example will | This example will get a player by '''handle''' and output his name on the chat. | ||
{{ClientsideCode| | {{ClientsideCode| | ||
<pre> | <pre> | ||
Latest revision as of 12:53, 4 January 2021
Function to get the entity with the given handle from his entity pool.
Syntax
Entity pool.atHandle(Number handle)
Required Arguments
- handle: Handle of the entity
Returns
- Entity Entity with specified handle, undefined if none exists.
Example
This example will get a player by handle and output his name on the chat.
Client-Side
function outputPlayerNameWithHandle(handle) {
const player = mp.players.atHandle(handle);
if (player) {
mp.gui.chat.push(`Player with handle ${handle} is named ${player.name}.`);
} else {
mp.gui.chat.push(`Player with handle ${handle} does not exist.`);
}
}
See Also
- Functions
- Properties
- Arrays