Skip to main content
Branch: Release Candidate

Player

Hierarchy

  • Entity
    • Player

Index

Properties

publicreadonlyaimPos

aimPos: Vector3

Position the player is currently aiming at.

publicreadonlyarmour

armour: number

Current armour.

publicreadonlycurrentWeapon

currentWeapon: number

Currently equipped weapon.

publicreadonlycurrentWeaponComponents

currentWeaponComponents: readonly number[]

Current weapon components.

publicreadonlycurrentWeaponTintIndex

currentWeaponTintIndex: number

Tint index for currently equipped weapon.

publicdimension

dimension: number

Object dimension.

Remarks

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

publicreadonlyentityAimOffset

entityAimOffset: Vector3

The current aim offset of the player.

publicreadonlyentityAimingAt

entityAimingAt: null | Entity

The entity the player is aiming at.

publicfilter

filter: null | AudioFilter

publicreadonlyflashlightActive

flashlightActive: boolean

Is the flashlight of the player activated.

publicreadonlyforwardSpeed

forwardSpeed: number

Forward speed of the player.

publicfrozen

frozen: boolean

publicreadonlyheadRot

headRot: Vector3

Rotation of the head of the player.

publicreadonlyhealth

health: number

Current health of the player.

publicreadonlyid

id: number

publicreadonlyisAiming

isAiming: boolean

Is the player currently aiming.

Remarks

Returns `true` ONLY if:

  • you are in first person with a gun equipped and you are not sprinting
  • you are in third person and aiming/shooting

publicreadonlyisCrouching

isCrouching: boolean

Is the player currently crouching.

publicreadonlyisDead

isDead: boolean

publicreadonlyisEnteringVehicle

isEnteringVehicle: boolean

publicreadonlyisInCover

isInCover: boolean

publicreadonlyisInMelee

isInMelee: boolean

publicreadonlyisInRagdoll

isInRagdoll: boolean

Is the player currently in ragdoll.

publicreadonlyisLeavingVehicle

isLeavingVehicle: boolean

publicreadonlyisOnLadder

isOnLadder: boolean

publicreadonlyisParachuting

isParachuting: boolean

publicreadonlyisReloading

isReloading: boolean

Is the player currently reloading their weapon.

publicreadonlyisRemote

isRemote: boolean

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

publicreadonlyisSpawned

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.

publicreadonlyisStealthy

isStealthy: boolean

Is the player currently stealthy.

publicreadonlyisTalking

isTalking: boolean

Player talking state

publicreadonlymaxArmour

maxArmour: number

Max available armour value.

publicreadonlymaxHealth

maxHealth: number

Current max health of the player.

publicreadonlymicLevel

micLevel: number

Player talking volume

publicreadonlymoveSpeed

moveSpeed: number

Current player movement speed.

publicreadonlyname

name: string

Player name

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.

publicnonSpatialVolume

nonSpatialVolume: number

Set & get the volume for 2D Voice.

Remarks

Value needs to be between 0-1.

publicpos

pos: Vector3

Object position.

Remarks

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

publicreadonlyrefCount

refCount: number

Returns the ref count of the entity.

Remarks

It’s only available in debug-mode.

publicreadonlyremoteID

remoteID: number

The serverside id of this entity.

publicrot

rot: Vector3

Entity rotation in radians

Remarks

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

publicreadonlyscriptID

scriptID: number

Internal game id that can be used in native calls

publicreadonlyseat

seat: number

Curent seat the player is sitting in. If player is not in any vehicle it is equal to 0.

Remarks

The seat indexes start with 1 (driver seat).

publicspatialVolume

spatialVolume: number

Set & get the volume for 3D Voice.

Remarks

Value needs to be between 0-1.

publicreadonlystrafeSpeed

strafeSpeed: number

Strafe speed of the player.

publicreadonlytaskData

taskData: string

publicreadonlytype

type: BaseObjectType

Type of the object.

publicreadonlyvalid

valid: boolean

Object usability.

Returns

False if object is no longer usable.

publicreadonlyvehicle

vehicle: null | Vehicle | LocalVehicle

Player’s vehicle, null if player is not in any vehicle

publicreadonlyvisible

visible: boolean

publicstaticreadonlyall

all: readonly Player[]

Array with all players.

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 players = alt.Player.all; // Store it in a variable, so it doesn't create a copy of the array on each iteration
for(let i = 0; i < players.length; i++)
{
alt.log(`${players[i].name}`); // Logs the name of every player
}

publicstaticreadonlycount

count: number

publicstaticreadonlylocal

local: LocalPlayer

The local player instance.

publicstaticreadonlystreamedIn

streamedIn: readonly Player[]

Array with all streamed in players.

Accessors

publicmodel

  • get model(): number

    Getter

  • Hash of entity model

Methods

publicdeleteMeta

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

publicdestroy

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

publicgetMeta

  • getMeta<K>(key: Exclude<K, never>): unknown
  • getMeta<K>(key: K): undefined | ICustomPlayerMeta[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 | ICustomPlayerStreamSyncedMeta[K]
  • getStreamSyncedMeta<V>(key: string): undefined | V
  • Type parameters

    • K: string

publicgetStreamSyncedMetaKeys

  • getStreamSyncedMetaKeys(): readonly string[]

publicgetSyncInfo

  • getSyncInfo(): ISyncInfo

publicgetSyncedMeta

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

    • K: string

publicgetSyncedMetaKeys

  • getSyncedMetaKeys(): readonly string[]

publicgetWeaponTintIndex

  • getWeaponTintIndex(weaponModel: string | number): number

publichasMeta

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

publichasStreamSyncedMeta

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

publichasSyncedMeta

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

publichasWeaponComponent

  • hasWeaponComponent(weaponModel: string | number, component: string | number): boolean

publicsetMeta

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

    • K: string

publicstaticgetByID

  • getByID(id: number): null | Player
  • Retrieves the player from the pool.

publicstaticgetByRemoteID

  • getByRemoteID(id: number): null | Player
  • Gets the player with the given remote id

publicstaticgetByScriptID

  • getByScriptID(scriptID: number): null | Player
  • Retrieves the player from the pool.