Skip to content

Player

@vimp-mp/types 2.0.1

Interface · Server API

Player currently connected to the server.

Instances are managed by the runtime: use vimp.players.all / vimp.players.getById(id) or receive them via event callbacks. Do not new this class directly.

ts
interface Player extends StreamSyncedMeta

Members

activeVoiceChannel

ts
readonly activeVoiceChannel: VoiceChannel | null

Voice channel currently selected by the player, or null.

ammo

ts
readonly ammo: number

Ammo count for the currently equipped weapon.

armour

ts
armour: number

Armour, typically 0-100.

currentWeapon

ts
readonly currentWeapon: number

Hash of the player's currently equipped weapon (0 = unarmed).

dimension

ts
dimension: number

Virtual world (dimension). The player sees and interacts only with entities in the same dimension. Defaults to 0.

Changing dimension while the player is in a vehicle automatically removes the player from it (PlayerVehicleStateChanged::Exited). The playerDimensionChange event is emitted after the change.

heading

ts
heading: number

Heading in degrees, 0-360.

health

ts
health: number

HP, 0-100.

id

ts
readonly id: number

Server-assigned player identifier.

isTalking

ts
readonly isTalking: boolean

Whether the player is currently transmitting voice audio.

model

ts
model: number

Current ped model hash (joaat).

name

ts
name: string

Display name. Lazy — fetched from the native layer on first access. Inside a playerDisconnected handler the value is a cached snapshot captured at disconnect time.

position

ts
position: Vec3 | null

Current world position, or null if the player has no spawned ped yet.

seat

ts
readonly seat: number

Seat index in the current vehicle (-1 = driver, 255 = none).

socialClub

ts
readonly socialClub: string

Social Club account name reported for the player.

vehicle

ts
readonly vehicle: Vehicle | null

Vehicle the player is currently seated in, or null.

voiceDeafened

ts
voiceDeafened: boolean

Whether the server prevents this player from receiving voice audio.

voiceMuted

ts
voiceMuted: boolean

Whether the server prevents this player from sending voice audio.

weapons

ts
readonly weapons: readonly Array<Weapon>

Snapshot of weapons currently owned by the player.

deleteStreamSyncedMeta

ts
deleteStreamSyncedMeta(key: string): void

Deletes key and propagates the removal to streaming clients.

emit

ts
emit<K extends never>(event: K, data: VimpClientInboundEvents[K]): boolean
ts
emit(event: string, data: unknown): boolean

Emit a custom event to this specific player's client. data is serialized to JSON unless it is already a string.

getStreamSyncedMeta

ts
getStreamSyncedMeta<T = unknown>(key: string): T | undefined

Returns undefined if the key is unset.

getStreamSyncedMetaKeys

ts
getStreamSyncedMetaKeys(): Array<string>

Returns all stream-synced metadata keys stored on the entity.

giveWeapon

ts
giveWeapon(hash: number, ammo: number): boolean

Gives the player a weapon with the requested initial ammunition.

hasStreamSyncedMeta

ts
hasStreamSyncedMeta(key: string): boolean

Returns whether the entity has a value for key.

kick

ts
kick(reason?: string): boolean

Disconnect this player from the server.

playAnimation

ts
playAnimation(dictionary: string, name: string, speed: number, flag: number): void

Starts an animation on the player's ped.

putIntoVehicle

ts
putIntoVehicle(vehicleId: number, seat?: number): boolean

Seat the player into vehicleId. seat defaults to -1 (driver).

removeAllWeapons

ts
removeAllWeapons(): boolean

Removes every weapon from the player's inventory.

removeFromVehicle

ts
removeFromVehicle(): boolean

Remove the player from their current vehicle.

removeWeapon

ts
removeWeapon(hash: number): boolean

Removes the weapon identified by hash from the player's inventory.

setActiveVoiceChannel

ts
setActiveVoiceChannel(channel: number | VoiceChannel | null): boolean

Selects the player's active channel, or clears it with null.

setStreamSyncedMeta

ts
setStreamSyncedMeta(key: string, value: unknown): void

Set or replace one key. The value is forwarded to every player currently streaming this entity, plus included in the snapshot for any future stream-in. Use deleteStreamSyncedMeta rather than undefined when the key must be removed.

setWeaponAmmo

ts
setWeaponAmmo(hash: number, ammo: number): boolean

Set the ammo count for an already-owned weapon. Returns false if the player does not currently have hash.

stopAnimation

ts
stopAnimation(): void

Stops the animation currently playing on the player's ped.

teleport

ts
teleport(x: number, y: number, z: number, heading?: number): boolean

Teleport the player. If heading is omitted, the current heading is kept.

VIMP developer documentation