Pool::exists: Difference between revisions
CocaColaBear (talk | contribs) (Created page with "This function used for check if pool contains entity. ==Syntax== <div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;"> <div style...") |
No edit summary |
||
| Line 1: | Line 1: | ||
This function used for check | This function is used for check, exists entity with ID in pool or not. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="javascript"> | |||
Boolean pool.exists(Number ID) | |||
</syntaxhighlight> | |||
===Returns=== | |||
Return true if entity exists, false if not exists. | |||
===Required Arguments=== | |||
*'''ID:''' Entity ID, what you wanna check in pool. | |||
==Example== | |||
This example will check player with ID in pool, and write player name into chat if he exists. | |||
<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> | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" highlight="1"> | ||
let isPlayerExists = mp.players.exists(1488); | |||
if (isPlayerExists) { | |||
let player = mp.players.at(1488); | |||
console.log(`Player with id 1488 exists and have nickname ${player.name}`); | |||
} else { | |||
console.log(`Player by id 1488 does not exists...`); | |||
}; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</div> | </div> | ||
==See Also== | ==See Also== | ||
{{EntityPool_function}} | {{EntityPool_function}} | ||
Revision as of 15:59, 26 September 2017
This function is used for check, exists entity with ID in pool or not.
Syntax
Boolean pool.exists(Number ID)
Returns
Return true if entity exists, false if not exists.
Required Arguments
- ID: Entity ID, what you wanna check in pool.
Example
This example will check player with ID in pool, and write player name into chat if he exists.
Server-Side
let isPlayerExists = mp.players.exists(1488);
if (isPlayerExists) {
let player = mp.players.at(1488);
console.log(`Player with id 1488 exists and have nickname ${player.name}`);
} else {
console.log(`Player by id 1488 does not exists...`);
};
See Also
- Functions
- Properties
- Arrays