SixL client API / game/decorator / GameDecoratorMp
Interface: GameDecoratorMp
Decorators: named values (a number, a flag or a time) that the game keeps on an entity. A property is registered with a type before it is set.
Remarks
Every getter returns a Promise. A property name given as a string is hashed (see GameNameOrHash).
Methods
decorExistOn()
decorExistOn(entity,property):Promise<boolean>
Tells whether an entity has a decorator with that property.
Parameters
entity
The entity.
property
The property's name, or its hash.
Returns
Promise<boolean>
A Promise of true when the decorator is set on the entity.
Example
const has = await mp.game.decorator.decorExistOn(vehicle.handle, 'locked');
decorGetBool()
decorGetBool(entity,property):Promise<boolean>
Reads a boolean decorator from an entity.
Parameters
entity
The entity.
property
The property's name, or its hash.
Returns
Promise<boolean>
A Promise of the stored flag.
Example
const locked = await mp.game.decorator.decorGetBool(vehicle.handle, 'locked');
decorGetInt()
decorGetInt(entity,property):Promise<number>
Reads an integer decorator from an entity.
Parameters
entity
The entity.
property
The property's name, or its hash.
Returns
Promise<number>
A Promise of the stored integer.
Example
const level = await mp.game.decorator.decorGetInt(ped.handle, 'level');
decorIsRegisteredAsType()
decorIsRegisteredAsType(property,type):Promise<boolean>
Tells whether a property name is registered with the given type.
Parameters
property
The property's name, or its hash.
type
number
The type, an integer in the game's numbering of decorator types.
Returns
Promise<boolean>
A Promise of true when the name is registered with that type.
Example
const ok = await mp.game.decorator.decorIsRegisteredAsType('level', 3);
decorRegister()
decorRegister(property,type):void
Registers a property name with a type, so that decorators of this name can be set.
Parameters
property
The property's name, or its hash.
type
number
The type, an integer in the game's numbering of decorator types.
Returns
void
Example
mp.game.decorator.decorRegister('level', 3);
decorRegisterLock()
decorRegisterLock(): void
Locks the decorator registry.
Returns
void
Remarks
The effect is inferred and not verified in the game.
Example
mp.game.decorator.decorRegisterLock();
decorRemove()
decorRemove(entity,property):Promise<boolean>
Removes a decorator from an entity.
Parameters
entity
The entity.
property
The property's name, or its hash.
Returns
Promise<boolean>
A Promise of true when the decorator was removed.
Example
const removed = await mp.game.decorator.decorRemove(vehicle.handle, 'locked');
decorSetTime()
decorSetTime(entity,property,timestamp):Promise<boolean>
Sets the time stamp of a decorator on an entity.
Parameters
entity
The entity.
property
The property's name, or its hash.
timestamp
number
The time stamp, an integer.
Returns
Promise<boolean>
A Promise of true when the value was set.
Remarks
The argument layout is inferred and not verified in the game.
Example
const ok = await mp.game.decorator.decorSetTime(vehicle.handle, 'job_started', 1700000000);