Pool::at: Difference between revisions

From RAGE Multiplayer Wiki
m (Reverted edits by YnnhoJ (talk) to last revision by Rootcause)
Tag: Rollback
m (A grammatical error was fixed.)
Line 18: Line 18:
console.log(`Player with id 1488 have nickname ${player.name}`);
console.log(`Player with id 1488 have nickname ${player.name}`);
} else {
} else {
console.log(`Player by id 1488 does not exists...`);
console.log(`Player by id 1488 does not exist...`);
};
};
</pre>
</pre>

Revision as of 23:27, 4 August 2021

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

Syntax

Entity pool.at(Number ID)

Returns

An entity with the selected ID from a pool, or undefined if entity with this ID does 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 exist...`);
};

See Also