Pool::length: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
m (Replaced HTML with template)
Line 4: Line 4:


==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">
<pre>
Number pool.length;
Number pool.length;
</syntaxhighlight>
</pre>


==Example==  
==Example==  
This example will return vehicles and players count.
This example will return vehicles and players count.
<div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;">
{{ServersideCode|
<div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div>
<pre>
<syntaxhighlight lang="javascript" highlight="2">
let getStuffCount = () => {
let getStuffCount = () => {
return [mp.players.length, mp.vehicles.length];
return [mp.players.length, mp.vehicles.length];
Line 19: Line 18:
let [players, vehicles] = getStuffCount();
let [players, vehicles] = getStuffCount();
console.log(`Server have ${vehicles} vehicles and ${players} players.`)
console.log(`Server have ${vehicles} vehicles and ${players} players.`)
</syntaxhighlight>
</pre>
</div>
}}


==See Also==
==See Also==
{{EntityPool_function}}
{{EntityPool_function}}

Revision as of 11:54, 26 October 2018

This property is used to get the element count of a pool.

Note: this property is read-only.

Syntax

Number pool.length;

Example

This example will return vehicles and players count.

Server-Side
let getStuffCount = () => {
	return [mp.players.length, mp.vehicles.length];
};

let [players, vehicles] = getStuffCount();
console.log(`Server have ${vehicles} vehicles and ${players} players.`)

See Also