Player
@vimp-mp/types 2.0.1Player 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.
interface Player extends StreamSyncedMetaMembers
activeVoiceChannel
readonly activeVoiceChannel: VoiceChannel | nullVoice channel currently selected by the player, or null.
ammo
readonly ammo: numberAmmo count for the currently equipped weapon.
armour
armour: numberArmour, typically 0-100.
currentWeapon
readonly currentWeapon: numberHash of the player's currently equipped weapon (0 = unarmed).
dimension
dimension: numberVirtual 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
heading: numberHeading in degrees, 0-360.
health
health: numberHP, 0-100.
id
readonly id: numberServer-assigned player identifier.
isTalking
readonly isTalking: booleanWhether the player is currently transmitting voice audio.
model
model: numberCurrent ped model hash (joaat).
name
name: stringDisplay 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
position: Vec3 | nullCurrent world position, or null if the player has no spawned ped yet.
seat
readonly seat: numberSeat index in the current vehicle (-1 = driver, 255 = none).
socialClub
readonly socialClub: stringSocial Club account name reported for the player.
vehicle
readonly vehicle: Vehicle | nullVehicle the player is currently seated in, or null.
voiceDeafened
voiceDeafened: booleanWhether the server prevents this player from receiving voice audio.
voiceMuted
voiceMuted: booleanWhether the server prevents this player from sending voice audio.
weapons
readonly weapons: readonly Array<Weapon>Snapshot of weapons currently owned by the player.
deleteStreamSyncedMeta
deleteStreamSyncedMeta(key: string): voidDeletes key and propagates the removal to streaming clients.
emit
emit<K extends never>(event: K, data: VimpClientInboundEvents[K]): booleanemit(event: string, data: unknown): booleanEmit a custom event to this specific player's client. data is serialized to JSON unless it is already a string.
getStreamSyncedMeta
getStreamSyncedMeta<T = unknown>(key: string): T | undefinedReturns undefined if the key is unset.
getStreamSyncedMetaKeys
getStreamSyncedMetaKeys(): Array<string>Returns all stream-synced metadata keys stored on the entity.
giveWeapon
giveWeapon(hash: number, ammo: number): booleanGives the player a weapon with the requested initial ammunition.
hasStreamSyncedMeta
hasStreamSyncedMeta(key: string): booleanReturns whether the entity has a value for key.
kick
kick(reason?: string): booleanDisconnect this player from the server.
playAnimation
playAnimation(dictionary: string, name: string, speed: number, flag: number): voidStarts an animation on the player's ped.
putIntoVehicle
putIntoVehicle(vehicleId: number, seat?: number): booleanSeat the player into vehicleId. seat defaults to -1 (driver).
removeAllWeapons
removeAllWeapons(): booleanRemoves every weapon from the player's inventory.
removeFromVehicle
removeFromVehicle(): booleanRemove the player from their current vehicle.
removeWeapon
removeWeapon(hash: number): booleanRemoves the weapon identified by hash from the player's inventory.
setActiveVoiceChannel
setActiveVoiceChannel(channel: number | VoiceChannel | null): booleanSelects the player's active channel, or clears it with null.
setStreamSyncedMeta
setStreamSyncedMeta(key: string, value: unknown): voidSet 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
setWeaponAmmo(hash: number, ammo: number): booleanSet the ammo count for an already-owned weapon. Returns false if the player does not currently have hash.
stopAnimation
stopAnimation(): voidStops the animation currently playing on the player's ped.
teleport
teleport(x: number, y: number, z: number, heading?: number): booleanTeleport the player. If heading is omitted, the current heading is kept.