Skip to main content

Object

Hierarchy

  • Entity
    • Object

Index

Constructors

constructor

  • new Object(model: string | number, position: IVector3, rotation: IVector3, alpha?: number, textureVariation?: number, lodDistance?: number, streamingDistance?: number): Object

Properties

publicalpha

alpha: number

Object transparency, values are between 0 and 255. (0 being fully transparent)

publiccollision

collision: boolean

publicdimension

dimension: number

Object dimension.

Remarks

Check https://docs.altv.mp/articles/dimensions.html to understand how it works.

publicfrozen

frozen: boolean

publicreadonlyid

id: number

publiclodDistance

lodDistance: number

The distance at which the LOD model of the object starts being applied.

publicreadonlynetOwner

netOwner: null | Player

Network owner of the entity.

Remarks

Network owner is responsible for syncing entity with the server. It changes when actual network owner passes the migration range, then the new one is determined based on distance from the entity (if entity is a vehicle, then the driver will take priority for becoming network owner). Disabling migration range will stop this process from happening until turned on again.

publicpos

pos: Vector3

Object position.

publicreadonlyrefCount

refCount: number

Returns the ref count of the entity.

Remarks

It’s only available in debug-mode.

publicrot

rot: Vector3

Entity rotation.

Remarks

Values are provided in radians.

publicstreamed

streamed: boolean

Whether the entity should be streamed for other entities.

publicstreamingDistance

streamingDistance: number

publictextureVariation

textureVariation: number

publicreadonlytimestamp

timestamp: number

publicreadonlytype

type: BaseObjectType

Type of the object.

publicreadonlyvalid

valid: boolean

Object usability.

Returns

False if object is no longer usable.

publicvisible

visible: boolean

Whether the entity is visible.

publicstaticreadonlyall

all: readonly Object[]

publicstaticreadonlycount

count: number

Accessors

publicmodel

  • get model(): number
  • set model(model: string | number): void

    Getter

  • Entity model hash.

    Setter

Methods

publicactivatePhysics

  • activatePhysics(): void

publicattachTo

  • attachTo(entity: Entity, entityBone: string | number, ownBone: string | number, pos: IVector3, rot: IVector3, enableCollisions: boolean, noFixedRotation: boolean): void
  • Attaches this entity to another entity.

publicdeleteMeta

  • deleteMeta(key: string): void
  • deleteMeta<K>(key: K): void

publicdeleteStreamSyncedMeta

  • deleteStreamSyncedMeta(key: string): void
  • deleteStreamSyncedMeta<K>(key: K): void
  • Removes the specified key and the data connected to that specific key.

publicdeleteSyncedMeta

  • deleteSyncedMeta(key: string): void
  • deleteSyncedMeta<K>(key: K): void
  • Removes the specified key and the data connected to that specific key.

publicdestroy

  • destroy(): void
  • Removes the object from the world.

publicdetach

  • detach(): void
  • Detaches this entity if attached to another entity.

publicgetMeta

  • getMeta<K>(key: Exclude<K, never>): unknown
  • getMeta<K>(key: K): undefined | ICustomEntityMeta[K]
  • getMeta<V>(key: string): undefined | V
  • Type parameters

    • K: string

publicgetMetaDataKeys

  • getMetaDataKeys(): readonly string[]

publicgetStreamSyncedMeta

  • getStreamSyncedMeta<K>(key: Exclude<K, never>): unknown
  • getStreamSyncedMeta<K>(key: K): undefined | ICustomEntityStreamSyncedMeta[K]
  • getStreamSyncedMeta<V>(key: string): undefined | V
  • Gets a value using the specified key.


    Type parameters

    • K: string

publicgetStreamSyncedMetaKeys

  • getStreamSyncedMetaKeys(): readonly string[]

publicgetSyncedMeta

  • getSyncedMeta<K>(key: Exclude<K, never>): unknown
  • getSyncedMeta<K>(key: K): undefined | ICustomEntitySyncedMeta[K]
  • getSyncedMeta<V>(key: string): undefined | V
  • Gets a value using the specified key.


    Type parameters

    • K: string

publicgetSyncedMetaKeys

  • getSyncedMetaKeys(): readonly string[]

publichasMeta

  • hasMeta(key: string): boolean
  • hasMeta<K>(key: K): boolean

publichasStreamSyncedMeta

  • hasStreamSyncedMeta(key: string): boolean
  • hasStreamSyncedMeta<K>(key: K): boolean
  • Determines whether contains the specified key.

publichasSyncedMeta

  • hasSyncedMeta(key: string): boolean
  • hasSyncedMeta<K>(key: K): boolean
  • Determines whether contains the specified key.

publicplaceOnGroundProperly

  • placeOnGroundProperly(): void
  • Places the object properly on the ground.

publicresetNetOwner

  • resetNetOwner(disableMigration?: boolean): void
  • Resets overwritten network owner.

    Remarks

    See Entity~netOwner to understand how network owner works.

    <p><b> Keep in mind that disabling migration can lead to unexpected behaviour when the network owner gets out of the streaming range. </b></p>

publicsetMeta

  • setMeta<K>(key: K, value: InterfaceValueByKey<ICustomEntityMeta, K, unknown, void>): void
  • setMeta<K>(key: K, value: ICustomEntityMeta[K]): void
  • setMeta<V, K>(key: K, value: InterfaceValueByKey<ICustomEntityMeta, K, V, void>): void
  • Type parameters

    • K: string

publicsetNetOwner

  • setNetOwner(player: Player, disableMigration?: boolean): void
  • Changes network owner to the specified player.

    Remarks

    See Entity~netOwner to understand how network owner works.

    <p><b> Keep in mind that disabling migration can lead to unexpected behaviour when the network owner gets out of the streaming range. </b></p>

publicsetStreamSyncedMeta

  • setStreamSyncedMeta<K>(key: K, value: InterfaceValueByKey<ICustomEntityStreamSyncedMeta, K, unknown, void>): void
  • setStreamSyncedMeta<K>(key: K, value: ICustomEntityStreamSyncedMeta[K]): void
  • setStreamSyncedMeta<V, K>(key: K, value: InterfaceValueByKey<ICustomEntityStreamSyncedMeta, K, V, void>): void
  • Stores the given value with the specified key.

    Remarks

    The given value will be shared with all clients in streaming range.


    Type parameters

    • K: string

publicsetSyncedMeta

  • setSyncedMeta<K>(key: K, value: InterfaceValueByKey<ICustomEntitySyncedMeta, K, unknown, void>): void
  • setSyncedMeta<K>(key: K, value: ICustomEntitySyncedMeta[K]): void
  • setSyncedMeta<V, K>(key: K, value: InterfaceValueByKey<ICustomEntitySyncedMeta, K, V, void>): void
  • Stores the given value with the specified key.

    Remarks

    The given value will be shared with all clients.


    Type parameters

    • K: string

publicstaticgetByID

  • getByID(id: number): null | Object