Pool::at: Difference between revisions

From RAGE Multiplayer Wiki
(Created page with "This function returns entity at specified id. ==Syntax== <syntaxhighlight lang="javascript"> pool.at( id ); </syntaxhighlight> ==Example== <syntaxhighlight lang="javascript...")
 
No edit summary
Line 1: Line 1:
This function returns entity at specified id.
This function used for return element from pool at ID.


==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
pool.at( id );
void pool.at(int ID)
</syntaxhighlight>  
</syntaxhighlight>  


==Example==
==Example==  
That's example will return player by ID and output his name in console.
 
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
console.log(mp.players.at(0).name);
let player = mp.players.at(1488);
if (!!player) {
console.log(`Player 1488 have nickname ${player.name}`);
} else {
console.log(`Player by id 1488 does not exists...`);
};
</syntaxhighlight>
</syntaxhighlight>
==See Also==
{{EntityPool_function}}

Revision as of 08:50, 5 May 2017

This function used for return element from pool at ID.

Syntax

void pool.at(int ID)

Example

That's example will return player by ID and output his name in console.

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

See Also