Pool::at: Difference between revisions

From RAGE Multiplayer Wiki
(Updated example border)
No edit summary
Line 3: Line 3:
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
void pool.at(int ID)
Entity pool.at(Number ID)
</syntaxhighlight>  
</syntaxhighlight>  
 
===Returns===
Return a entity with selected ID, from a pool. Or false, if entity with this ID not exists.
===Required Arguments===
===Required Arguments===
*'''ID:''' Element ID, what you need get from the pool.
*'''ID:''' Element ID, what you need get from the pool.
==Example==  
==Example==  
This example will return a player by ID and output his name in the console.
This example will return a player by ID and output his name in the console.
<div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;">
<div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;">
<div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div>
<div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div>

Revision as of 15:00, 26 September 2017

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

Syntax

Entity pool.at(Number ID)

Returns

Return a entity with selected ID, from a pool. Or false, if entity with this ID not exists.

Required Arguments

  • ID: Element ID, what you need get from the pool.

Example

This example will return a player by ID and output his name in the console.

Server-Side
let player = mp.players.at(1488);
if (player) {
	console.log(`Player with id 1488 have nickname ${player.name}`);
} else {
	console.log(`Player by id 1488 does not exists...`);
};

See Also