Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LocalPed

Hierarchy

Index

Constructors

constructor

  • new LocalPed(model: string | number, dimension: number, pos: IVector3, rot: IVector3): LocalPed
  • new LocalPed(model: string | number, dimension: number, pos: IVector3, rot: IVector3, useStreaming: true, streamingDistance: number): LocalPed
  • Creates static local ped without streaming enabled.

    Parameters

    Returns LocalPed

  • Creates local ped with streaming enabled.

    Parameters

    • model: string | number
    • dimension: number
    • pos: IVector3
    • rot: IVector3
    • useStreaming: true
    • streamingDistance: number

    Returns LocalPed

Properties

Readonly armour

armour: number

Current armour.

Readonly currentWeapon

currentWeapon: number

Currently equipped weapon.

dimension

dimension: number

Object dimension.

remarks

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

frozen

frozen: boolean

Readonly health

health: number

Current health of the ped.

Readonly id

id: number

Readonly isRemote

isRemote: boolean

Whether this entity was created clientside or serverside. (Clientside = false, Serverside = true).

Readonly isSpawned

isSpawned: boolean

Returns whether the entity is spawned in the game world.

remarks

This does the same thing as checking if the scriptID is 0.

Readonly isStreamedIn

isStreamedIn: boolean

Readonly maxHealth

maxHealth: number

Current max health of the ped.

Readonly netOwner

netOwner: Player | null

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.

pos

pos: Vector3

Object position.

remarks

Setting this throws an error if the client is not the network owner of an entity

Readonly refCount

refCount: number

Returns the ref count of the entity.

remarks

It's only available in debug-mode.

Readonly remoteID

remoteID: number

The serverside id of this entity.

rot

rot: Vector3

Readonly scriptID

scriptID: number

Readonly streamingDistance

streamingDistance: number

Readonly type

Type of the object.

Readonly valid

valid: boolean

Object usability.

returns

False if object is no longer usable.

visible

visible: boolean

Static Readonly all

all: readonly Ped[]

Static Readonly count

count: number

Static Readonly streamedIn

streamedIn: readonly Ped[]

Accessors

model

  • get model(): number
  • set model(model: number | string): any
  • Returns number

  • Parameters

    • model: number | string

    Returns any

Methods

deleteMeta

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

destroy

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

    Returns void

getMeta

  • getMeta<K>(key: Exclude<K, keyof ICustomPedMeta>): unknown
  • getMeta<K>(key: K): ICustomPedMeta[K] | undefined
  • Type parameters

    • K: string

    Parameters

    Returns unknown

  • Type parameters

    Parameters

    • key: K

    Returns ICustomPedMeta[K] | undefined

getMetaDataKeys

  • getMetaDataKeys(): readonly string[]

getStreamSyncedMeta

  • getStreamSyncedMeta<K>(key: Exclude<K, keyof ICustomPedStreamSyncedMeta>): unknown
  • getStreamSyncedMeta<K>(key: K): ICustomPedStreamSyncedMeta[K] | undefined

getStreamSyncedMetaKeys

  • getStreamSyncedMetaKeys(): readonly string[]

getSyncInfo

getSyncedMeta

  • getSyncedMeta<K>(key: Exclude<K, keyof ICustomPedSyncedMeta>): unknown
  • getSyncedMeta<K>(key: K): ICustomPedSyncedMeta[K] | undefined

getSyncedMetaKeys

  • getSyncedMetaKeys(): readonly string[]

hasMeta

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

    • key: string

    Returns boolean

  • Type parameters

    Parameters

    • key: K

    Returns boolean

hasStreamSyncedMeta

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

hasSyncedMeta

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

setMeta

  • setMeta<K>(key: K, value: shared.InterfaceValueByKey<ICustomPedMeta, K>): void
  • setMeta<K>(key: K, value: ICustomPedMeta[K]): void
  • Type parameters

    • K: string

    Parameters

    Returns void

  • Type parameters

    Parameters

    • key: K
    • value: ICustomPedMeta[K]

    Returns void

waitForSpawn

  • waitForSpawn(timeout?: number): Promise<void>
  • Waits asynchronously until the ped spawns.

    Parameters

    • Optional timeout: number

    Returns Promise<void>

Static getByID

  • Retrieves the localPed from the pool.

    Parameters

    • id: number

      The id of the entity.

    Returns LocalPed | null

    Entity if it was found, otherwise null.

Static getByRemoteID

  • getByRemoteID(id: number): Ped | null

Static getByScriptID

  • getByScriptID(scriptID: number): LocalPed | null
  • Retrieves the localPed from the pool.

    Parameters

    • scriptID: number

      The script id of the entity.

    Returns LocalPed | null

    Entity if it was found, otherwise null.