Skip to main content
Branch: Development

Entity

Hierarchy

  • WorldObject
    • Entity

Index

Properties

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

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

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 Entity[]

Array with all entities.

Remarks

This creates a clone of the array everytime it is called. It is advised to call this once and store the result in a variable, before iterating over it.

Example

const entities = alt.Entity.all; // Store it in a variable, so it doesn't create a copy of the array on each iteration
for(let i = 0; i < entities.length; i++)
{
alt.log(`${entities[i].id}`); // Logs the id of every entity
}

Accessors

publicmodel

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

    Getter

  • Entity model hash.

Methods

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.

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(type: BaseObjectType, id: number): null | BaseObject
  • Gets the base object with the given type and id