Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Player

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

Protected constructor

Properties

Readonly aimPos

aimPos: Vector3

Position the player is currently aiming at.

remarks

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

armour

armour: number

Readonly authToken

authToken: string

Readonly cloudAuthResult

cloudAuthResult: CloudAuthResult

Readonly cloudID

cloudID: string

collision

collision: boolean

Readonly currentAnimationDict

currentAnimationDict: number

Readonly currentAnimationName

currentAnimationName: number

Readonly currentInterior

currentInterior: number

currentWeapon

currentWeapon: number

Readonly currentWeaponComponents

currentWeaponComponents: readonly number[]

Readonly currentWeaponTintIndex

currentWeaponTintIndex: number

dimension

dimension: number

Object dimension.

remarks

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

Readonly discordID

discordID: string

Readonly entityAimOffset

entityAimOffset: Vector3

Readonly entityAimingAt

entityAimingAt: Entity | null

Readonly flashlightActive

flashlightActive: boolean

Readonly forwardSpeed

forwardSpeed: number

frozen

frozen: boolean

Readonly headRot

headRot: Vector3

health

health: number

Readonly hwidExHash

hwidExHash: string

Readonly hwidHash

hwidHash: string

Readonly id

id: number

invincible

invincible: boolean

Readonly ip

ip: string

Readonly isAiming

isAiming: boolean

Readonly isCrouching

isCrouching: boolean

Readonly isDead

isDead: boolean

Readonly isEnteringVehicle

isEnteringVehicle: boolean

Readonly isInCover

isInCover: boolean

Readonly isInMelee

isInMelee: boolean

Readonly isInRagdoll

isInRagdoll: boolean

Readonly isLeavingVehicle

isLeavingVehicle: boolean

Readonly isOnLadder

isOnLadder: boolean

Readonly isParachuting

isParachuting: boolean

Readonly isReloading

isReloading: boolean

The player's state of weapon reloading.

Readonly isSpawned

isSpawned: boolean

Readonly isStealthy

isStealthy: boolean

Readonly isSuperJumpEnabled

isSuperJumpEnabled: boolean

lastDamagedBodyPart

lastDamagedBodyPart: number

maxArmour

maxArmour: number

maxHealth

maxHealth: number

Readonly moveSpeed

moveSpeed: number

Readonly name

name: string

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.

netOwnershipDisabled

netOwnershipDisabled: boolean

Readonly ping

ping: number

pos

pos: Vector3

Object position.

Readonly refCount

refCount: number

Returns the ref count of the entity.

remarks

It's only available in debug-mode.

rot

rot: Vector3

Entity rotation.

remarks

Values are provided in radians.

Readonly seat

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

sendNames

sendNames: boolean

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

Readonly socialClubName

socialClubName: string

Readonly socialID

socialID: string

Readonly strafeSpeed

strafeSpeed: number

streamed

streamed: boolean

Whether the entity should be streamed for other entities.

Readonly streamedEntities

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

streamingDistance

streamingDistance: number

Readonly timestamp

timestamp: number

Readonly type

Type of the object.

Readonly valid

valid: boolean

Object usability.

returns

False if object is no longer usable.

Readonly vehicle

vehicle: Vehicle | null

visible

visible: boolean

Whether the entity is visible.

Readonly weapons

weapons: readonly IWeapon[]

Static Readonly all

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
}

Static Readonly count

count: number

Accessors

model

  • get model(): number
  • set model(model: number | string): any
  • Entity model hash.

    Returns number

  • Entity model hash.

    Parameters

    • model: number | string

    Returns any

Methods

addDecoration

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

    • collection: string | number
    • overlay: string | number
    • Optional count: number

    Returns void

addWeaponComponent

  • addWeaponComponent(weaponHash: number, component: number): void
  • Parameters

    • weaponHash: number
    • component: number

    Returns void

attachTo

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

    Parameters

    • entity: Entity

      Target entity.

    • entityBone: number | string

      Target bone id or name.

    • ownBone: number | string

      Origin bone id or name.

    • pos: IVector3

      Position offset.

    • rot: IVector3

      Rotation - needs to be in radians.

    • enableCollisions: boolean

      If true the attached entity has a collision.

    • noFixedRotation: boolean

      If false the entity is attached with a fixed rotation (no bouncing). That means if the value in native was true, you have to use false in the serverside method

    Returns void

clearBloodDamage

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

    Returns void

clearClothes

  • clearClothes(component: number): void
  • Parameters

    • component: number

    Returns void

clearDecorations

  • clearDecorations(): void
  • Returns void

clearProp

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

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

    Parameters

    • component: number

      Component id of the prop.

    Returns void

clearTasks

  • clearTasks(): void
  • Returns void

deleteLocalMeta

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

    • key: string

    Returns void

  • Type parameters

    Parameters

    • key: K

    Returns void

deleteMeta

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

    • key: string

    Returns void

  • Type parameters

    Parameters

    • key: K

    Returns void

deleteStreamSyncedMeta

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

deleteSyncedMeta

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

despawn

  • despawn(): void
  • Returns void

destroy

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

    Returns void

detach

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

    Returns void

emit

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

    Type parameters

    Parameters

    • eventName: K

      Name of the event.

    • Rest ...args: Parameters<ICustomServerClientEvent[K]>

      Rest parameters for emit to send.

    Returns void

  • Type parameters

    • K: string

    Parameters

    Returns void

emitRaw

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

    Type parameters

    Parameters

    • eventName: K

      Name of the event.

    • Rest ...args: Parameters<ICustomServerClientEvent[K]>

      Rest parameters for emit to send.

    Returns void

  • Type parameters

    • K: string

    Parameters

    Returns void

emitRpc

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

    Type parameters

    Parameters

    • rpcName: K

      Name of the RPC

    • Rest ...args: Parameters<ICustomServerClientRpc[K]>

    Returns Promise<ReturnType<ICustomServerClientRpc[K]>>

  • Type parameters

    • K: string

    Parameters

    Returns Promise<any>

getAmmo

  • getAmmo(ammoHash: number | string): number
  • Parameters

    • ammoHash: number | string

    Returns number

getAmmoFlags

  • getAmmoFlags(ammoHash: number | string): IAmmoFlags
  • Parameters

    • ammoHash: number | string

    Returns IAmmoFlags

getAmmoMax

  • getAmmoMax(ammoHash: number | string): number
  • Parameters

    • ammoHash: number | string

    Returns number

getAmmoMax100

  • getAmmoMax100(ammoHash: number | string): number
  • Parameters

    • ammoHash: number | string

    Returns number

getAmmoMax50

  • getAmmoMax50(ammoHash: number | string): number
  • Parameters

    • ammoHash: number | string

    Returns number

getAmmoSpecialType

  • Parameters

    • ammoHash: number | string

    Returns AmmoSpecialType

getBloodDamageBase64

  • getBloodDamageBase64(): string
  • Returns string

getClothes

  • 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
    

    Parameters

    • component: number

      Component id of the clothing.

    Returns ICloth

getDecorations

  • Returns readonly IDecoration[]

getDlcClothes

  • 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
    

    Parameters

    • component: number

      Component id of the clothing.

    Returns IDlcCloth

getDlcProp

  • 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
    

    Parameters

    • component: number

      Component id of the prop.

    Returns IDlcProp

getEyeColor

  • getEyeColor(): number
  • Returns number

getFaceFeatureScale

  • getFaceFeatureScale(index: number): number
  • Parameters

    • index: number

    Returns number

getHairColor

  • getHairColor(): number
  • Returns number

getHairHighlightColor

  • getHairHighlightColor(): number
  • Returns number

getHeadBlendData

getHeadBlendPaletteColor

  • getHeadBlendPaletteColor(id: number): RGBA
  • Parameters

    • id: number

    Returns RGBA

getHeadOverlay

  • Parameters

    • overlayID: number

    Returns IHeadOverlay

getLocalMeta

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

    Type parameters

    • K: string

    Parameters

    Returns unknown

    Dynamic value associated with the specified key or undefined if no data is present.

  • Type parameters

    Parameters

    • key: K

    Returns ICustomPlayerLocalMeta[K] | undefined

  • Type parameters

    • V: any

    Parameters

    • key: string

    Returns V | undefined

getLocalMetaKeys

  • getLocalMetaKeys(): readonly string[]
  • Returns readonly string[]

getMeta

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

    • K: string

    Parameters

    Returns unknown

  • Type parameters

    Parameters

    • key: K

    Returns ICustomPlayerMeta[K] | undefined

  • deprecated

    See ICustomPlayerMeta

    Type parameters

    • V: any

    Parameters

    • key: string

    Returns V | undefined

getMetaDataKeys

  • getMetaDataKeys(): readonly string[]

getProp

  • 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
    

    Parameters

    • component: number

      Component id of the prop.

    Returns IProp

getStreamSyncedMeta

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

getStreamSyncedMetaKeys

  • getStreamSyncedMetaKeys(): readonly string[]

getSyncedMeta

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

getSyncedMetaKeys

  • getSyncedMetaKeys(): readonly string[]

getWeaponAmmo

  • getWeaponAmmo(weaponHash: number | string): number
  • Parameters

    • weaponHash: number | string

    Returns number

giveWeapon

  • 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
    

    Parameters

    • weaponModel: string | number

      The model of the weapon.

    • ammo: number

      Amount of ammo to spawn the weapon with. See remarks for more information.

    • equipNow: boolean

      Should the weapon be equipped immediately.

    Returns void

hasLocalMeta

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

    • key: string

    Returns boolean

  • Type parameters

    Parameters

    • key: K

    Returns boolean

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

hasWeapon

  • hasWeapon(weaponModel: string | number): boolean
  • Parameters

    • weaponModel: string | number

    Returns boolean

hasWeaponComponent

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

    • weaponModel: string | number
    • component: string | number

    Returns boolean

isEntityInStreamRange

  • 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
    

    Parameters

    Returns boolean

kick

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

    Parameters

    • Optional reason: string

      The reason that will display to the player on the disconnect screen. If not specified, it defaults to "KICKED_OUT".

    Returns void

playAmbientSpeech

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

playAnimation

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

    • animDict: string
    • animName: string
    • Optional blendInSpeed: number
    • Optional blendOutSpeed: number
    • Optional duration: number
    • Optional flags: number
    • Optional playbackRate: number
    • Optional lockX: boolean
    • Optional lockY: boolean
    • Optional lockZ: boolean

    Returns void

playScenario

  • playScenario(name: string): void
  • Parameters

    • name: string

    Returns void

removeAllWeapons

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

    Parameters

    • Optional removeAllAmmo: boolean

    Returns void

removeDecoration

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

    • collection: string | number
    • overlay: string | number

    Returns void

removeFaceFeature

  • removeFaceFeature(index: number): boolean
  • Parameters

    • index: number

    Returns boolean

removeHeadBlendData

  • removeHeadBlendData(): void
  • Returns void

removeHeadBlendPaletteColor

  • removeHeadBlendPaletteColor(): void
  • Returns void

removeHeadOverlay

  • removeHeadOverlay(overlayID: number): boolean
  • Parameters

    • overlayID: number

    Returns boolean

removeWeapon

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

    Parameters

    • weaponHash: number

      Hash of the weapon.

    Returns void

removeWeaponComponent

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

    Parameters

    • weaponHash: number

      Hash of the weapon.

    • component: number

      Hash of the weapon component.

    Returns void

resetNetOwner

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

    remarks

    See {@link Entity~netOwner} to understand how network owner works.

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

    Parameters

    • Optional disableMigration: boolean

      Pass true to disable migration, false to keep it enabled. If not specified, it defaults to "false".

    Returns void

setAmmo

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

    • ammoHash: number | string
    • ammo: number

    Returns void

setAmmoFlags

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

    • ammoHash: number | string
    • infiniteAmmo: boolean
    • addSmokeOnExplosion: boolean
    • fuse: boolean
    • fixedAfterExplosion: boolean

    Returns void

setAmmoMax

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

    • ammoHash: number | string
    • ammoMax: number

    Returns void

setAmmoMax100

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

    • ammoHash: number | string
    • ammoMax: number

    Returns void

setAmmoMax50

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

    • ammoHash: number | string
    • ammoMax: number

    Returns void

setAmmoSpecialType

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

    Returns void

setBloodDamageBase64

  • setBloodDamageBase64(base64: string): void
  • Parameters

    • base64: string

    Returns void

setClothes

  • 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
    

    Parameters

    • component: number

      Component id of the clothing.

    • drawable: number

      Drawable id of the clothing.

    • texture: number

      Texture id of the clothing.

    • Optional palette: number

      Palette of the clothing.

    Returns boolean

setDateTime

setDlcClothes

  • 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);
    

    Parameters

    • dlc: number

      Dlc hash of the clothing.

    • component: number

      Component id of the clothing.

    • drawable: number

      Drawable id of the clothing.

    • texture: number

      Texture id of the clothing.

    • Optional palette: number

      Palette of the clothing.

    Returns boolean

setDlcProp

  • 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);
    

    Parameters

    • dlc: number

      Dlc hash of the prop.

    • component: number

      Component id of the prop.

    • drawable: number

      Drawable id of the prop.

    • texture: number

      Texture id of the prop.

    Returns boolean

setEyeColor

  • setEyeColor(eyeColor: number): boolean
  • Parameters

    • eyeColor: number

    Returns boolean

setFaceFeature

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

    • index: number
    • scale: number

    Returns boolean

setHairColor

  • setHairColor(hairColor: number): void
  • Parameters

    • hairColor: number

    Returns void

setHairHighlightColor

  • setHairHighlightColor(hairHighlightColor: number): void
  • Parameters

    • hairHighlightColor: number

    Returns void

setHeadBlendData

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

    • shapeFirstID: number
    • shapeSecondID: number
    • shapeThirdID: number
    • skinFirstID: number
    • skinSecondID: number
    • skinThirdID: number
    • shapeMix: number
    • skinMix: number
    • thirdMix: number

    Returns void

setHeadBlendPaletteColor

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

    • id: number
    • red: number
    • green: number
    • blue: number

    Returns boolean

setHeadOverlay

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

    • overlayID: number
    • index: number
    • opacity: number

    Returns boolean

setHeadOverlayColor

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

    • overlayID: number
    • colorType: number
    • colorIndex: number
    • secondColorIndex: number

    Returns boolean

setIntoVehicle

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

    remarks

    The seat indexes start with 1 (driver seat).

    Parameters

    Returns void

setLocalMeta

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

    Type parameters

    • K: string

    Parameters

    • key: K

      The key of the value to store.

    • value: shared.InterfaceValueByKey<ICustomPlayerLocalMeta, K>

      The value to store.

    Returns void

  • Type parameters

    Parameters

    • key: K
    • value: ICustomPlayerLocalMeta[K]

    Returns void

  • Type parameters

    • V: any

    • K: string = string

    Parameters

    Returns void

setMeta

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

    • K: string

    Parameters

    Returns void

  • Type parameters

    Parameters

    • key: K
    • value: ICustomPlayerMeta[K]

    Returns void

  • deprecated

    See ICustomPlayerMeta

    Type parameters

    • V: any

    • K: string = string

    Parameters

    Returns void

setNetOwner

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

    remarks

    See {@link Entity~netOwner} to understand how network owner works.

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

    Parameters

    • player: Player

      The given player that will be set as new network owner.

    • Optional disableMigration: boolean

      Pass true to disable migration, false to keep it enabled. If not specified, it defaults to "false".

    Returns void

setProp

  • 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
    

    Parameters

    • component: number

      Component id of the prop.

    • drawable: number

      Drawable id of the prop.

    • texture: number

      Texture id of the prop.

    Returns boolean

setStreamSyncedMeta

  • setStreamSyncedMeta<K>(key: K, value: shared.InterfaceValueByKey<ICustomPlayerStreamSyncedMeta, K>): void
  • setStreamSyncedMeta<K>(key: K, value: ICustomPlayerStreamSyncedMeta[K]): void
  • setStreamSyncedMeta<V, K>(key: K, value: shared.InterfaceValueByKey<ICustomPlayerStreamSyncedMeta, K, V>): void

setSyncedMeta

  • setSyncedMeta<K>(key: K, value: shared.InterfaceValueByKey<ICustomPlayerSyncedMeta, K>): void
  • setSyncedMeta<K>(key: K, value: ICustomPlayerSyncedMeta[K]): void
  • setSyncedMeta<V, K>(key: K, value: shared.InterfaceValueByKey<ICustomPlayerSyncedMeta, K, V>): void

setWeaponAmmo

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

    • weaponHash: number | string
    • ammo: number

    Returns void

setWeaponTintIndex

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

    • weaponHash: number
    • tintIndex: number

    Returns void

setWeather

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

    Returns void

  • Type parameters

    • T: number

    Parameters

    • weatherType: T

    Returns void

spawn

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

    Parameters

    • x: number

      The x position where the player gets spawned.

    • y: number

      The y position where the player gets spawned.

    • z: number

      The z position where the player gets spawned.

    • Optional delay: number

      The delay at which the player gets spawned after calling this function. Defaults to 0.

    Returns void

  • Spawns the player in the world.

    remarks

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

    Parameters

    • pos: IVector3

      The position where the player gets spawned.

    • Optional delay: number

      The delay at which the player gets spawned after calling this function. Defaults to 0.

    Returns void

  • Sets the model and spawns the player in the world.

    Parameters

    • model: string | number

      The model to be set to the player before spawning.

    • pos: IVector3

      The position where the player gets spawned.

    Returns void

Static getByID

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

    Parameters

    • id: number

      The id of the player.

    Returns Player | null

    Player if it was found, otherwise null.