SixL server API / world-entities / DummyMpPool
Interface: DummyMpPool
The pool of dummy entities: mp.dummies.
Remarks
Raises the events dummyEntityCreated and dummyEntityDestroyed (with the dummy).
Example
mp.dummies.forEachByType(7, (d) => d.destroy());
Extends
Properties
length
readonlylength:number
The number of entities in the pool.
Example
const count = mp.blips.length;
Inherited from
Methods
at()
at(id):DummyMp
Finds an entity by id.
Parameters
id
number
The entity's id.
Returns
The entity, or null when there is none.
Example
const blip = mp.blips.at(1);
Inherited from
exists()
exists(entity):boolean
Whether an entity (or an id) is still in the pool.
Parameters
entity
number | DummyMp
An entity or its id.
Returns
boolean
True when it exists.
Example
if (mp.blips.exists(blip)) { }
Inherited from
forEach()
forEach(callingFunction):void
Calls a function for every entity.
Parameters
callingFunction
(entity) => void
Called with each entity.
Returns
void
Example
mp.blips.forEach((b) => b.destroy());
Inherited from
forEachByType()
forEachByType(dummyEntityType,fn):void
Calls a function for every dummy of a type.
Parameters
dummyEntityType
number
The type number.
fn
(entity) => void
Called with each dummy.
Returns
void
Remarks
Server only: dummies are not sent to the clients.
Example
mp.dummies.forEachByType(7, (d) => console.log(d.id));
forEachFast()
forEachFast(callingFunction):void
Calls a function for every entity; the same as forEach in SixL.
Parameters
callingFunction
(entity) => void
Called with each entity.
Returns
void
Example
mp.blips.forEachFast((b) => b.destroy());
Inherited from
new()
new(dummyEntityType,sharedVariables?):DummyMp
Creates a dummy entity.
Parameters
dummyEntityType
number
A number that tells your dummies apart.
sharedVariables?
Optional. Variables to set at once.
Returns
The dummy.
Example
const quest = mp.dummies.new(7, { stage: 1 });
toArray()
toArray(): DummyMp[]
A snapshot of all entities.
Returns
DummyMp[]
A new array; changing it does not change the pool.
Example
const all = mp.blips.toArray();