Skip to main content

Player

Hierarchy

  • Entity
    • Player

Index

Properties

Accessors

Methods

Properties

publicreadonlyaimPos

aimPos: Vector3

Position the player is currently aiming at.

Remarks

Will return zero if the player is aiming against a entity.

publicarmour

armour: number

publicreadonlyauthToken

authToken: string

publicreadonlycloudAuthResult

cloudAuthResult: CloudAuthResult

publicreadonlycloudID

cloudID: string

publiccollision

collision: boolean

publicreadonlycurrentAnimationDict

currentAnimationDict: number

publicreadonlycurrentAnimationName

currentAnimationName: number

publicreadonlycurrentInterior

currentInterior: number

publiccurrentWeapon

currentWeapon: number

publicreadonlycurrentWeaponComponents

currentWeaponComponents: readonly number[]

publicreadonlycurrentWeaponTintIndex

currentWeaponTintIndex: number

publicdimension

dimension: number

Object dimension.

Remarks

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

publicreadonlydiscordID

discordID: string

publicreadonlyentityAimOffset

entityAimOffset: Vector3

publicreadonlyentityAimingAt

entityAimingAt: null | Entity

publicreadonlyflashlightActive

flashlightActive: boolean

publicreadonlyforwardSpeed

forwardSpeed: number

publicfrozen

frozen: boolean

publicreadonlyheadRot

headRot: Vector3

publichealth

health: number

publicreadonlyhwidExHash

hwidExHash: string

publicreadonlyhwidHash

hwidHash: string

publicreadonlyid

id: number

publicinvincible

invincible: boolean

publicreadonlyip

ip: string

publicreadonlyisAiming

isAiming: boolean

publicreadonlyisCrouching

isCrouching: boolean

publicreadonlyisDead

isDead: boolean

publicreadonlyisEnteringVehicle

isEnteringVehicle: boolean

publicreadonlyisInCover

isInCover: boolean

publicreadonlyisInMelee

isInMelee: boolean

publicreadonlyisInRagdoll

isInRagdoll: boolean

publicreadonlyisLeavingVehicle

isLeavingVehicle: boolean

publicreadonlyisOnLadder

isOnLadder: boolean

publicreadonlyisParachuting

isParachuting: boolean

publicreadonlyisReloading

isReloading: boolean

The player’s state of weapon reloading.

publicreadonlyisSpawned

isSpawned: boolean

publicreadonlyisStealthy

isStealthy: boolean

publicreadonlyisSuperJumpEnabled

isSuperJumpEnabled: boolean

publiclastDamagedBodyPart

lastDamagedBodyPart: number

publicmaxArmour

maxArmour: number

publicmaxHealth

maxHealth: number

publicreadonlymoveSpeed

moveSpeed: number

publicreadonlyname

name: string

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.

publicnetOwnershipDisabled

netOwnershipDisabled: boolean

publicreadonlyping

ping: number

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.

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).

publicsendNames

sendNames: boolean

Send names of all players on server to this player if they are not already sent (value is not set to true).

publicreadonlysocialClubName

socialClubName: string

publicreadonlysocialID

socialID: string

publicreadonlystrafeSpeed

strafeSpeed: number

publicstreamed

streamed: boolean

Whether the entity should be streamed for other entities.

publicreadonlystreamedEntities

streamedEntities: readonly { distance: number; entity: Entity }[]

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.

publicreadonlyvehicle

vehicle: null | Vehicle

publicvisible

visible: boolean

Whether the entity is visible.

publicreadonlyweapons

weapons: readonly IWeapon[]

publicstaticreadonlyall

all: readonly Player[]

Array with all players connected to the server.

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

Accessors

publicmodel

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

    Getter

  • Entity model hash.

    Setter

Methods

publicaddDecoration

  • addDecoration(collection: string | number, overlay: string | number, count?: number): void

publicaddWeaponComponent

  • addWeaponComponent(weaponHash: number, component: number): 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.

publicclearBloodDamage

  • clearBloodDamage(): void
  • Removes the visible blood on the player body.

publicclearClothes

  • clearClothes(component: number): void

publicclearDecorations

  • clearDecorations(): void

publicclearProp

  • clearProp(component: number): void
  • Removes a specified prop component.

    Example

    player.clearProp(0); // removes the player hat prop

publicclearTasks

  • clearTasks(): void

publicdeleteLocalMeta

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

publicdeleteMeta

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

publicdeleteStreamSyncedMeta

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

publicdeleteSyncedMeta

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

publicdespawn

  • despawn(): void

publicdestroy

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

publicdetach

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

publicemit

  • emit<K>(eventName: K, ...args: Parameters<ICustomServerClientEvent[K]>): void
  • emit<K>(eventName: Exclude<K, never>, ...args: any[]): void
  • Emits specified event to client.


    Type parameters

    • K: never

publicemitRaw

  • emitRaw<K>(eventName: K, ...args: Parameters<ICustomServerClientEvent[K]>): void
  • emitRaw<K>(eventName: Exclude<K, never>, ...args: any[]): void
  • Emits specified event to client, but faster as emit.


    Type parameters

    • K: never

publicemitRpc

  • emitRpc<K>(rpcName: K, ...args: Parameters<ICustomServerClientRpc[K]>): Promise<ReturnType<ICustomServerClientRpc[K]>>
  • emitRpc<K>(rpcName: Exclude<K, never>, ...args: any[]): Promise<any>
  • Calls a client sided RPC with the specified arguments.


    Type parameters

    • K: never

publicgetAmmo

  • getAmmo(ammoHash: string | number): number

publicgetAmmoFlags

  • getAmmoFlags(ammoHash: string | number): IAmmoFlags

publicgetAmmoMax

  • getAmmoMax(ammoHash: string | number): number

publicgetAmmoMax100

  • getAmmoMax100(ammoHash: string | number): number

publicgetAmmoMax50

  • getAmmoMax50(ammoHash: string | number): number

publicgetAmmoSpecialType

  • getAmmoSpecialType(ammoHash: string | number): AmmoSpecialType

publicgetBloodDamageBase64

  • getBloodDamageBase64(): string

publicgetClothes

  • getClothes(component: number): ICloth
  • Gets the specified clothing component.

    Example

    let cloth = player.getClothes(1); // Gets the currently equipped mask
    alt.log(cloth.drawable); // Logs the drawable of the currently equipped mask

publicgetDecorations

  • getDecorations(): readonly IDecoration[]

publicgetDlcClothes

  • getDlcClothes(component: number): IDlcCloth
  • Gets the specified dlc clothing component.

    Example

    let cloth = player.getDlcClothes(1); // Gets the currently equipped mask
    alt.log(cloth.drawable); // Logs the drawable of the currently equipped mask

publicgetDlcProp

  • getDlcProp(component: number): IDlcProp
  • Gets the specified dlc prop component.

    Example

    let prop = player.getDlcProp(0); // Gets the hat prop of the player
    alt.log(prop.drawable); // Logs the drawable id of the current hat prop of the player

publicgetEyeColor

  • getEyeColor(): number

publicgetFaceFeatureScale

  • getFaceFeatureScale(index: number): number

publicgetHairColor

  • getHairColor(): number

publicgetHairHighlightColor

  • getHairHighlightColor(): number

publicgetHeadBlendData

  • getHeadBlendData(): IHeadBlendData

publicgetHeadBlendPaletteColor

  • getHeadBlendPaletteColor(id: number): RGBA

publicgetHeadOverlay

  • getHeadOverlay(overlayID: number): IHeadOverlay

publicgetLocalMeta

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


    Type parameters

    • K: string

publicgetLocalMetaKeys

  • getLocalMetaKeys(): readonly string[]

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

publicgetProp

  • getProp(component: number): IProp
  • Gets the specified prop component.

    Example

    let prop = player.getProp(0); // Gets the hat prop of the player
    alt.log(prop.drawable); // Logs the drawable id of the current hat prop of the player

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

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

publicgetWeaponAmmo

  • getWeaponAmmo(weaponHash: string | number): number

publicgiveWeapon

  • giveWeapon(weaponModel: string | number, ammo: number, equipNow: boolean): void
  • Gives the specified weapon to the player.

    Remarks

    Amount of given ammo is shared between all weapons with the same ammo type. For example pistols: weapon_pistol and weapon_combatpistol have same ammo pool.

    See https://gist.github.com/root-cause/faf41f59f7a6d818b7db0b839bd147c1 for a list of ammo types.

    Some more notes about weapon ammo:

    • Zero ammo value doesnt remove ammo of that weapon.
    • Negative ammo value enables infinite ammo for this ammo type.
    • Amount of ammo will be added if player already have weapon with same ammo type.

    Example

    player.giveWeapon(alt.hash('weapon_pistol'), 10, true); // sets amount ammo of type "AMMO_PISTOL" to 10
    player.giveWeapon(alt.hash('weapon_combatpistol'), 0, true); // also 10 amount of ammo, as this has the same type of ammo
    player.giveWeapon(alt.hash('weapon_pistol'), 10, true); // adds amount ammo of type "AMMO_PISTOL", so 20 pistol ammo in result

publichasLocalMeta

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

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

publichasWeapon

  • hasWeapon(weaponModel: string | number): boolean

publichasWeaponComponent

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

publicisEntityInStreamRange

  • isEntityInStreamRange(entity: Entity): boolean
  • Checks whether the given entity is in the stream range of the player.

    Example

    if(player.vehicle) alt.log(player.isEntityInStreamRange(player.vehicle)); // This always logs true, because their own vehicle is always in stream range of the player

publickick

  • kick(reason?: string): void
  • Forcefully disconnects the player with a reason message.

publicplayAmbientSpeech

  • playAmbientSpeech(speechName: string, speechParam: string, speechDictHash: number): void

publicplayAnimation

  • playAnimation(animDict: string, animName: string, blendInSpeed?: number, blendOutSpeed?: number, duration?: number, flags?: number, playbackRate?: number, lockX?: boolean, lockY?: boolean, lockZ?: boolean): void

publicplayScenario

  • playScenario(name: string): void

publicremoveAllWeapons

  • removeAllWeapons(removeAllAmmo?: boolean): void
  • Removes every weapon from the player.

publicremoveDecoration

  • removeDecoration(collection: string | number, overlay: string | number): void

publicremoveFaceFeature

  • removeFaceFeature(index: number): boolean

publicremoveHeadBlendData

  • removeHeadBlendData(): void

publicremoveHeadBlendPaletteColor

  • removeHeadBlendPaletteColor(): void

publicremoveHeadOverlay

  • removeHeadOverlay(overlayID: number): boolean

publicremoveWeapon

  • removeWeapon(weaponHash: number): void
  • Removes the specified weapon from the player.

publicremoveWeaponComponent

  • removeWeaponComponent(weaponHash: number, component: number): void
  • Removes the specified weapon component from the specified weapon.

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>

publicsetAmmo

  • setAmmo(ammoHash: string | number, ammo: number): void

publicsetAmmoFlags

  • setAmmoFlags(ammoHash: string | number, infiniteAmmo: boolean, addSmokeOnExplosion: boolean, fuse: boolean, fixedAfterExplosion: boolean): void

publicsetAmmoMax

  • setAmmoMax(ammoHash: string | number, ammoMax: number): void

publicsetAmmoMax100

  • setAmmoMax100(ammoHash: string | number, ammoMax: number): void

publicsetAmmoMax50

  • setAmmoMax50(ammoHash: string | number, ammoMax: number): void

publicsetAmmoSpecialType

  • setAmmoSpecialType(ammoHash: string | number, ammoSpecialType: AmmoSpecialType): void

publicsetBloodDamageBase64

  • setBloodDamageBase64(base64: string): void

publicsetClothes

  • setClothes(component: number, drawable: number, texture: number, palette?: number): boolean
  • Sets the specified clothing component.

    Remarks

    The dlc hash is only required when setting dlc clothing.

    Example

    player.setClothes(1, 14, 0); // Sets the players mask to a blue hockey mask

publicsetDateTime

  • setDateTime(day: DateTimeDay, month: DateTimeMonth, year: number, hour: DateTimeHour, minute: DateTimeMinute, second: DateTimeSecond): void

publicsetDlcClothes

  • setDlcClothes(dlc: number, component: number, drawable: number, texture: number, palette?: number): boolean
  • Sets the specified dlc clothing component.

    Remarks

    The dlc hash is only required when setting dlc clothing.

    Example

    player.setDlcClothes(alt.hash('dlcname'), 1, 14, 0);

publicsetDlcProp

  • setDlcProp(dlc: number, component: number, drawable: number, texture: number): boolean
  • Sets the specified dlc prop component.

    Example

    player.setDlcProp(alt.hash('dlcname'), 0, 13, 0);

publicsetEyeColor

  • setEyeColor(eyeColor: number): boolean

publicsetFaceFeature

  • setFaceFeature(index: number, scale: number): boolean

publicsetHairColor

  • setHairColor(hairColor: number): void

publicsetHairHighlightColor

  • setHairHighlightColor(hairHighlightColor: number): void

publicsetHeadBlendData

  • setHeadBlendData(shapeFirstID: number, shapeSecondID: number, shapeThirdID: number, skinFirstID: number, skinSecondID: number, skinThirdID: number, shapeMix: number, skinMix: number, thirdMix: number): void

publicsetHeadBlendPaletteColor

  • setHeadBlendPaletteColor(id: number, red: number, green: number, blue: number): boolean

publicsetHeadOverlay

  • setHeadOverlay(overlayID: number, index: number, opacity: number): boolean

publicsetHeadOverlayColor

  • setHeadOverlayColor(overlayID: number, colorType: number, colorIndex: number, secondColorIndex: number): boolean

publicsetIntoVehicle

  • setIntoVehicle(vehicle: Vehicle, seat: number): void
  • Set the player into a vehicle on specific seat.

    Remarks

    The seat indexes start with 1 (driver seat).

publicsetLocalMeta

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


    Type parameters

    • K: string

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

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>

publicsetProp

  • setProp(component: number, drawable: number, texture: number): boolean
  • Sets the specified prop component.

    Example

    player.setProp(0, 13, 0); // sets the players hat prop to a blue cowboy hat

publicsetStreamSyncedMeta

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

    • K: string

publicsetSyncedMeta

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

    • K: string

publicsetWeaponAmmo

  • setWeaponAmmo(weaponHash: string | number, ammo: number): void

publicsetWeaponTintIndex

  • setWeaponTintIndex(weaponHash: number, tintIndex: number): void

publicsetWeather

  • setWeather(weatherType: WeatherType): void
  • setWeather<T>(weatherType: T): void

publicspawn

  • spawn(x: number, y: number, z: number, delay?: number): void
  • spawn(pos: IVector3, delay?: number): void
  • spawn(model: string | number, pos: IVector3): void
  • Spawns the player in the world.

    Remarks

    The player has to have a model set before being spawned.

publicstaticgetByID

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