Pool::exists: Difference between revisions
No edit summary |
m (Replaced HTML with template) |
||
| Line 2: | Line 2: | ||
==Syntax== | ==Syntax== | ||
< | <pre> | ||
Boolean pool.exists(Number ID) | Boolean pool.exists(Number ID) | ||
</ | </pre> | ||
===Returns=== | ===Returns=== | ||
Return true if entity exists, false if not exists. | Return true if entity exists, false if not exists. | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''ID:''' Entity ID, what you wanna check in pool. | *'''ID:''' Entity ID, what you wanna check in pool. | ||
==Example== | ==Example== | ||
This example will check player with ID in pool, and write player name into chat if he exists. | This example will check player with ID in pool, and write player name into chat if he exists. | ||
{{ServersideCode| | |||
<pre> | |||
< | |||
let isPlayerExists = mp.players.exists(1488); | let isPlayerExists = mp.players.exists(1488); | ||
if (isPlayerExists) { | if (isPlayerExists) { | ||
| Line 21: | Line 23: | ||
console.log(`Player by id 1488 does not exists...`); | console.log(`Player by id 1488 does not exists...`); | ||
}; | }; | ||
</ | </pre> | ||
}} | |||
==See Also== | ==See Also== | ||
{{EntityPool_function}} | {{EntityPool_function}} | ||
Revision as of 12:10, 26 October 2018
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