UNPKG

@altv/types-client

Version:

This package contains types definitions for alt:V client-side module.

1,565 lines (1,298 loc) 153 kB
/// <reference types="@altv/types-shared"/> /// <reference lib="es2017.sharedmemory"/> /** * @module alt-client */ declare module "alt-client" { import * as shared from "alt-shared"; export enum Locale { Arabic = "ar", Belarusian = "by", Czech = "cz", German = "de", English = "en", Spanish = "es", Farsi = "fa", French = "fr", Hebrew = "he", Hungarian = "hu", Indonesian = "id", Hindi = "in_hd", // Wrong tag (hi_in) Malayalam = "in_ml", // Wrong tag (ml_in) Telugu = "in_tl", // Wrong tag (te_in) Tamil = "in_tm", // Wrong tag (ta_in) Italian = "it", Lithuanian = "lt", Latvian = "lv", NorwegianBokmal = "nb_no", NorwegianNynorsk = "nn_no", Polish = "pl", Portugese = "pt", BrazilianPortuguese = "pt_br", Romanian = "ro", Serbian = "rs", // Wrong tag (sr) Russian = "ru", Slovak = "sk", Thai = "th", Turkish = "tr", Ukrainian = "ua", // Wrong tag (uk) ChineseSimplified = "zh_cn", ChineseTraditional = "zh_tw", } export enum StatName { Stamina = "stamina", Strength = "strength", LungCapacity = "lung_capacity", Wheelie = "wheelie_ability", Flying = "flying_ability", Shooting = "shooting_ability", Stealth = "stealth_ability", } export enum VehicleIndicatorLights { None = 0, BlinkLeft = 1, BlinkRight = 2, BlinkPermBoth = 4, StaticBoth = 8, Interior = 64, } export enum WebSocketReadyState { Connecting, Open, Closing, Closed, } export enum ConfigFlag { DisableAutoWeaponSwap = "DISABLE_AUTO_WEAPON_SWAP", DisablePedPropKnockOff = "DISABLE_PED_PROP_KNOCK_OFF", DisableIdleCamera = "DISABLE_IDLE_CAMERA", DisableVehicleEngineShutdownOnLeave = "DISABLE_VEHICLE_ENGINE_SHUTDOWN_ON_LEAVE", DisableSPEnterVehicleClipset = "DISABLE_SP_ENTER_VEHICLE_CLIPSET", ForceRenderSnow = "FORCE_RENDER_SNOW", ForceHideNightProps = "FORCE_HIDE_NIGHT_PROPS", ForceShowNightProps = "FORCE_SHOW_NIGHT_PROPS", DisableEmissiveLightsRendering = "DISABLE_EMISSIVE_LIGHTS_RENDERING", /** * Forces vehicle tyre burst even if 0 damage is applied. * Useful when damage in weapon meta is set to 0, and is calculated manually by script in event. */ ForceVehicleTyreBurst = "FORCE_VEHICLE_TYRE_BURST", /** * Prevents head props from being hidden when getting into the vehicle. * Equivalent to calling `setPedResetFlag` native with flag 337 in every tick. */ SwapAllowHeadPropInVehicleFlag = "SWAP_ALLOW_HEAD_PROP_IN_VEHICLE_FLAG", } /** @deprecated This method will be removed in the next major release. (v17) */ export enum WatermarkPosition { BottomRight = 0, TopRight = 1, TopLeft = 2, TopCenter = 3, BottomCenter = 4, } export enum GameFont { ChaletLondon, HouseScript, Monospace, CharletComprimeColonge = 4, Pricedown = 7, } export enum TextAlign { Center, Left, Rigth, } export enum TextLabelAlignment { Left, Right, Center, Justify, } export enum CookieSameSite { NoRestriction = "NO_RESTRICTION", LaxMode = "LAX_MODE", StrictMode = "STRICT_MODE", } export enum CookiePriority { Low = "LOW", Medium = "MEDIUM", High = "HIGH", } export interface IClientEvent { anyResourceError: (resourceName: string) => void; anyResourceStart: (resourceName: string) => void; anyResourceStop: (resourceName: string) => void; /** * @remarks The seat indexes start with 1 (driver seat). */ changedVehicleSeat: (vehicle: Vehicle, oldSeat: number, seat: number) => void; connectionComplete: () => void; consoleCommand: (name: string, ...args: string[]) => void; disconnect: () => void; /** * @remarks The seat indexes start with 1 (driver seat). */ enteredVehicle: (vehicle: Vehicle, seat: number) => void; gameEntityCreate: (entity: Entity) => void; gameEntityDestroy: (entity: Entity) => void; keydown: (key: shared.KeyCode) => void; keyup: (key: shared.KeyCode) => void; /** * @remarks The seat indexes start with 1 (driver seat). */ leftVehicle: (vehicle: Vehicle, seat: number) => void; /** * @remarks The seat indexes start with 1 (driver seat). */ startEnteringVehicle: (vehicle: Vehicle, seat: number, player: Player) => boolean | void; /** * @remarks The seat indexes start with 1 (driver seat). */ startLeavingVehicle: (vehicle: Vehicle, seat: number, player: Player) => boolean | void; removeEntity: (object: Entity) => void; resourceStart: (errored: boolean) => void; resourceStop: () => void; resourceError: (error: Error, file: string, line: number, stackTrace: string) => void; syncedMetaChange: (entity: Entity, key: string, value: any, oldValue: any) => void; streamSyncedMetaChange: (object: BaseObject, key: string, value: any, oldValue: any) => void; globalMetaChange: (key: string, value: any, oldValue: any) => void; globalSyncedMetaChange: (key: string, value: any, oldValue: any) => void; /** * @remarks See https://alloc8or.re/gta5/doc/enums/eTaskTypeIndex.txt for task ids. */ taskChange: (oldTask: number, newTask: number) => boolean | void; spawned: () => void; localMetaChange: (key: string, newValue: any, oldValue: any) => void; /** * @remarks Triggers only if the old or new owner is the local player. */ netOwnerChange: (entity: Entity, owner: Player | null, oldOwner: Player | null) => void; windowFocusChange: (isFocused: boolean) => void; windowResolutionChange: (oldResolution: shared.Vector2, newResolution: shared.Vector2) => void; playerAnimationChange: (target: Player, oldAnimDict: number, newAnimDict: number, oldAnimName: number, newAnimName: number) => void; playerWeaponShoot: (weaponHash: number, totalAmmo: number, ammoInClip: number) => void; playerWeaponChange: (oldWeapon: number, newWeapon: number) => void; baseObjectCreate: (baseObject: BaseObject) => void; baseObjectRemove: (baseObject: BaseObject) => void; weaponDamage: (target: Entity, weaponHash: number, damage: number, offset: shared.Vector3, bodyPart: shared.BodyPart, sourceEntity: Entity) => number | boolean | void; /** * Triggers when an Virtual Entity position is changed */ worldObjectPositionChange: (object: WorldObject, oldPosition: shared.Vector3) => void; worldObjectStreamIn: (object: WorldObject) => void; worldObjectStreamOut: (object: WorldObject) => void; metaChange: (target: BaseObject, key: string, value: any, oldValue: any) => void; entityEnterColshape: (colshape: Colshape, entity: Entity) => void; entityLeaveColshape: (colshape: Colshape, entity: Entity) => void; entityHitEntity: (damager: Entity, target: Entity, weaponHash: number) => void; playerBulletHit: (weaponHash: number, victim: Entity, position: shared.Vector3) => void; voiceConnection: (state: shared.VoiceConnectionState) => void; playerStartTalking: (target: Player) => void; playerStopTalking: (target: Player) => void; /** * @remarks This event is only triggered for local player. */ playerDimensionChange: (player: Player, oldDimension: number, newDimension: number) => void; /** * @remarks This event is only triggered for local player. */ playerInteriorChange: (player: Player, oldInterior: number, newInterior: number) => void; } export interface IDiscordUser { readonly id: string; readonly name: string; readonly discriminator: string; readonly avatar: string; } /** * Vehicle handling, which affects how vehicle responds and reacts to the inputs of a driver. * This handling applies to particular vehicle instance, as opposed to the {@link HandlingData}. * * @remarks Changes will be reflected only on a particular instance of the vehicle. On creation, model handling will be used as a base and changed properties will be added on top of it. */ export interface IVehicleHandling { readonly handlingNameHash: number; acceleration: number; antiRollBarBiasFront: number; antiRollBarBiasRear: number; antiRollBarForce: number; brakeBiasFront: number; brakeBiasRear: number; brakeForce: number; camberStiffness: number; centreOfMassOffset: shared.Vector3; clutchChangeRateScaleDownShift: number; clutchChangeRateScaleUpShift: number; collisionDamageMult: number; damageFlags: number; deformationDamageMult: number; downforceModifier: number; driveBiasFront: number; driveBiasRear: number; driveInertia: number; driveMaxFlatVel: number; engineDamageMult: number; handBrakeForce: number; handlingFlags: number; inertiaMultiplier: shared.Vector3; initialDragCoeff: number; initialDriveForce: number; initialDriveGears: number; initialDriveMaxFlatVel: number; lowSpeedTractionLossMult: number; mass: number; modelFlags: number; monetaryValue: number; oilVolume: number; percentSubmerged: number; percentSubmergedRatio: number; petrolTankVolume: number; rollCentreHeightFront: number; rollCentreHeightRear: number; seatOffsetDistX: number; seatOffsetDistY: number; seatOffsetDistZ: number; steeringLock: number; steeringLockRatio: number; suspensionBiasFront: number; suspensionBiasRear: number; suspensionCompDamp: number; suspensionForce: number; suspensionLowerLimit: number; suspensionRaise: number; suspensionReboundDamp: number; suspensionUpperLimit: number; tractionBiasFront: number; tractionBiasRear: number; tractionCurveLateral: number; tractionCurveLateralRatio: number; tractionCurveMax: number; tractionCurveMaxRatio: number; tractionCurveMin: number; tractionCurveMinRatio: number; tractionLossMult: number; tractionSpringDeltaMax: number; tractionSpringDeltaMaxRatio: number; unkFloat1: number; unkFloat2: number; unkFloat4: number; unkFloat5: number; weaponDamageMult: number; /** * Indicates whether vehicle handling was modified. * * @returns `true` if vehicle handling was modified; otherwise, `false`. */ isModified(): boolean; /** * Resets the vehicle handling back to a model handling. */ reset(): void; } export interface IHttpResponse { readonly statusCode: number; readonly body: string; readonly headers: Record<string, string>; } export interface IHeapStats { readonly heapSizeLimit: number; readonly totalHeapSize: number; readonly usedHeapSize: number; readonly mallocedMemory: number; readonly peakMallocedMemory: number; } /** * Follows Chrome DevTools cpuprofile format. * See [Chrome DevTools protocol docs](https://chromedevtools.github.io/devtools-protocol/tot/Profiler/#type-Profile) for more details. * * In order to analyze resulting Profile - serialize this class as JSON and put to a .cpuprofile file. * It will be available to use in DevTools on "Performance" tab, or in Visual Studio Code. * * @example * ```js * // server * alt.onClient("saveProfile", (player, name, content) => { * fs.writeFileSync("./" + name + ".cpuprofile", content); * }); * * // client * alt.Profile.startProfiling("test"); * // do some stuff * const profile = alt.Profile.stopProfiling("test"); * const content = JSON.stringify(profile); * alt.emitServer("saveProfile", "test", content); * ``` */ export interface IProfile { /** * The list of profile nodes. First item is the root node. */ readonly nodes: readonly IProfileNode[]; /** * Profiling start timestamp in microseconds. */ readonly startTime: number; /** * Profiling end timestamp in microseconds. */ readonly endTime: number; /** * Ids of samples top nodes. */ readonly samples: readonly number[]; /** * Time intervals between adjacent samples in microseconds. The first delta is relative to the profile startTime. */ readonly timeDeltas: readonly number[]; } export interface IProfileCallFrame { /** * JavaScript function name. */ readonly functionName: string; /** * Unique id of the script. */ readonly scriptId: number; /** * File path. */ readonly url: string; /** * JavaScript script line number (0-based). */ readonly lineNumber: number; /** * JavaScript script column number (0-based). */ readonly columnNumber: number; } export interface IProfileNode { /** * Unique id of the node. */ readonly id: number; /** * Function location. */ readonly callFrame: IProfileCallFrame; /** * Number of samples where this node was on top of the call stack. */ readonly hitCount: number; /** * Child node ids. */ readonly children?: readonly number[]; /** * The reason of being not optimized. The function may be deoptimized or marked as don't optimize. */ readonly deoptReason?: string; /** * An array of source position ticks. */ readonly positionTicks: readonly IProfileTickInfo[]; } export interface IProfileTickInfo { /** * Source line number (1-based). */ readonly line: number; /** * Number of samples attributed to the source line. */ readonly ticks: number; } /** * Extend it by interface merging for use in baseobject meta {@link "alt-client".BaseObject getMeta method}, {@link "alt-client".BaseObject setMeta method}, etc. * * @remarks See {@link "alt-shared".ICustomGlobalMeta} for an example of use. */ export interface ICustomBaseObjectMeta extends shared.ICustomBaseObjectMeta {} /** * Extend it by interface merging for use in blip meta {@link "alt-client".Blip getMeta method}, {@link "alt-client".Blip setMeta method}, etc. * * @remarks See {@link "alt-shared".ICustomGlobalMeta} for an example of use. */ export interface ICustomBlipMeta extends ICustomBaseObjectMeta {} /** * Extend it by merging interfaces for use in checkpoint meta {@link "alt-client".Checkpoint getMeta method}, {@link "alt-client".Checkpoint setMeta method}, etc. * * @remarks See {@link "alt-shared".ICustomGlobalMeta} for an example of use. */ export interface ICustomCheckpointMeta extends ICustomBaseObjectMeta {} /** * Extend it by interface merging for use in colshape meta {@link "alt-server".Colshape getMeta method}, {@link "alt-server".Colshape setMeta method}, etc. * * @remarks See {@link "alt-shared".ICustomGlobalMeta} for an example of use. */ export interface ICustomColshapeMeta extends ICustomBaseObjectMeta {} /** * Extend it by merging interfaces for use in webview meta {@link "alt-client".WebView getMeta method}, {@link "alt-client".WebView setMeta method}, etc. * * @remarks See {@link "alt-shared".ICustomGlobalMeta} for an example of use. */ export interface ICustomWebViewMeta extends ICustomBaseObjectMeta {} /** * Extend it by merging interfaces for use in audio meta {@link "alt-client".Audio getMeta method}, {@link "alt-client".Audio setMeta method}, etc. * * @remarks See {@link "alt-shared".ICustomGlobalMeta} for an example of use. */ export interface ICustomAudioMeta extends ICustomBaseObjectMeta {} /** * Extend it by interface merging for use in entity meta {@link "alt-client".Entity getMeta method}, {@link "alt-client".Entity setMeta method}, etc. * * @remarks See {@link "alt-shared".ICustomGlobalMeta} for an example of use. */ export interface ICustomEntityMeta extends ICustomBaseObjectMeta {} /** * Extend it by merging interfaces for use in player meta {@link "alt-client".Player getMeta method}, {@link "alt-client".Player setMeta method}, etc. * * @remarks See {@link "alt-shared".ICustomGlobalMeta} for an example of use. */ export interface ICustomPlayerMeta extends ICustomEntityMeta {} /** * Extend it by merging interfaces for use in local player meta {@link "alt-client".LocalPlayer getMeta method}, {@link "alt-client".LocalPlayer setMeta method}, etc. * * @remarks See {@link "alt-shared".ICustomGlobalMeta} for an example of use. */ export interface ICustomLocalPlayerMeta extends ICustomPlayerMeta {} /** * Extend it by merging interfaces for use in vehicle meta {@link "alt-client".Vehicle getMeta method}, {@link "alt-client".Vehicle setMeta method}, etc. * * @remarks See {@link "alt-shared".ICustomGlobalMeta} for an example of use. */ export interface ICustomVehicleMeta extends ICustomEntityMeta {} /** * Extend it by merging interfaces for use in vehicle meta {@link "alt-client".Ped getMeta method}, {@link "alt-client".Ped setMeta method}, etc. * * @remarks See {@link "alt-shared".ICustomGlobalMeta} for an example of use. */ export interface ICustomPedMeta extends ICustomEntityMeta {} /** * Extend `alt.emit` auto-completion by merging interfaces for use with `alt.emit`. * * @example * ```ts * declare module 'alt-client' { * interface ICustomEmitEvent { * myEvent: (arg1: string, arg2: { key: string, value: number }) * } * } * ``` * * @export * @interface ICustomEmitEvent */ export interface ICustomEmitEvent {} export interface IMarkerOptions { type?: number; dir?: shared.IVector3; rot?: shared.IVector3; scale?: shared.IVector3; color?: shared.RGBA; bobUpAndDown?: boolean; faceCamera?: boolean; p19?: number; rotate?: boolean; textureDict?: string | undefined; textureName?: string | undefined; drawOnEnts?: boolean; } export interface IInputDevice { readonly name: string; readonly uuid: string | null; } export interface ISyncInfo { readonly active: boolean; readonly receivedTick: number; readonly fullyReceivedTick: number; readonly sendTick: number; readonly ackedSendTick: number; readonly propertyCount: number; readonly componentCount: number; /** * 2D array of property update ticks grouped by component */ readonly propertyUpdateTicks: number[][]; } /** * Axis-Aligned Bounding Box. */ export interface IAABB { min: number; max: number; } export interface IWebViewParams { url: string; pos?: shared.IVector2; size?: shared.IVector2; isOverlay?: boolean; drawableHash?: number; targetTexture?: string; headers?: Record<string, string>; cookies?: ICookie[]; } export interface ICookie { /** * Cookie name must always start with "__altv_" */ name: `__altv_${string}`; url: string; value: unknown; httpOnly?: boolean; secure?: boolean; domain?: string; path?: string; sameSite?: CookieSameSite; priority: CookiePriority; expires: number; } export class BaseObject extends shared.BaseObject { /** * Whether this entity was created clientside or serverside. (Clientside = false, Serverside = true). * */ public readonly isRemote: boolean; /** * The serverside id of this entity. * */ public readonly remoteID: number; /** * Gets the base object with the given type and local id */ public static getByID(type: shared.BaseObjectType, id: number): BaseObject | null; public static getByRemoteID(type: shared.BaseObjectType, id: number): BaseObject | null; public deleteMeta(key: string): void; public deleteMeta<K extends shared.ExtractStringKeys<ICustomBaseObjectMeta>>(key: K): void; public hasMeta(key: string): boolean; public hasMeta<K extends shared.ExtractStringKeys<ICustomBaseObjectMeta>>(key: K): boolean; public getMeta<K extends string>(key: Exclude<K, keyof ICustomBaseObjectMeta>): unknown; public getMeta<K extends shared.ExtractStringKeys<ICustomBaseObjectMeta>>(key: K): ICustomBaseObjectMeta[K] | undefined; /** @deprecated See {@link ICustomBaseObjectMeta} */ public getMeta<V extends any>(key: string): V | undefined; public setMeta<K extends string>(key: K, value: shared.InterfaceValueByKey<ICustomBaseObjectMeta, K>): void; public setMeta<K extends shared.ExtractStringKeys<ICustomBaseObjectMeta>>(key: K, value: ICustomBaseObjectMeta[K]): void; /** @deprecated See {@link ICustomBaseObjectMeta} */ public setMeta<V extends any, K extends string = string>(key: K, value: shared.InterfaceValueByKey<ICustomBaseObjectMeta, K, V>): void; public setMeta(values: shared.MetaValues<ICustomBaseObjectMeta>): void; } /** [Documentation](https://docs.altv.mp/articles/virtualentity.html) */ export class VirtualEntityGroup extends BaseObject { /** * Creates a new Virtual Entity Group * * @param maxEntitiesInStream Max number of entities per player stream. [More info](https://docs.altv.mp/articles/virtualentity.html#what-is-max-number-of-entities-per-player-stream). */ public constructor(maxEntitiesInStream: number); /** Returns all Virtual Entity Group instances */ public static readonly all: readonly VirtualEntityGroup[]; /** * Max number of entities per player stream. * [More info](https://docs.altv.mp/articles/virtualentity.html#what-is-max-number-of-entities-per-player-stream). */ public readonly maxEntitiesInStream: number; } /** [Documentation](https://docs.altv.mp/articles/virtualentity.html) */ export class VirtualEntity extends WorldObject { /** Creates a new Virtual Entity */ public constructor(group: VirtualEntityGroup, position: shared.Vector3, streamingDistance: number, data?: Record<string, any>); /** Returns all Virtual Entity instances */ public static readonly all: readonly VirtualEntity[]; public static readonly streamedIn: readonly VirtualEntity[]; /** Virtual Entity Group this entity belongs to */ public readonly group: VirtualEntityGroup; public readonly isStreamedIn: boolean; public visible: boolean; /** * Gets a value using the specified key. * Only available for server-side created Virtual Entities. * * @param key The key of the value to get. * @returns Dynamic value associated with the specified key or undefined if no data is present. */ public getStreamSyncedMeta<K extends string>(key: Exclude<K, keyof shared.ICustomVirtualEntityStreamSyncedMeta>): unknown; public getStreamSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomVirtualEntityStreamSyncedMeta>>(key: K): shared.ICustomVirtualEntityStreamSyncedMeta[K] | undefined; /** @deprecated See {@link "alt-shared".ICustomVirtualEntityStreamSyncedMeta} */ public getStreamSyncedMeta<V extends any>(key: string): V | undefined; /** * Determines whether contains the specified key. * Only available for server-side created Virtual Entities. * * @param key The key of the value to locate. * @returns True if the meta table contains any data at the specified key or False if not */ public hasStreamSyncedMeta(key: string): boolean; public hasStreamSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomVirtualEntityStreamSyncedMeta>>(key: K): boolean; /** * Returns all set meta keys of the Virtual Entity. * Only available for server-side created Virtual Entities. */ public getStreamSyncedMetaKeys(): readonly string[]; } export class Audio extends BaseObject { /** * Creates a new Audio instance. * * @param source The source url of the audio. * @param volume The volume of the audio. Ranges from 0 to 1. */ public constructor(source: string, volume?: number, radio?: boolean, clearCache?: boolean); public static readonly all: readonly Audio[]; public static readonly count: number; /** * Retrieves the audio from the pool. * * @param id The id of the audio. * @returns Entity if it was found, otherwise null. */ public static getByID(id: number): Audio | null; public source: string; public looped: boolean; public volume: number; public readonly currentTime: number; public readonly maxTime: number; public readonly playing: boolean; /** * @remarks This method has no effect if the {@link frontendPlay} property returns true. */ public addOutput(output: AudioOutput): void; /** * @remarks This method has no effect if the {@link frontendPlay} property returns true. */ public removeOutput(output: AudioOutput): void; /** * @remarks This method has no effect if the {@link frontendPlay} property returns true. */ public getOutputs(): readonly (AudioOutput | number)[]; public play(): void; public pause(): void; public reset(): void; public seek(time: number): void; public on(event: "inited", callback: () => void): void; public on(event: "streamStarted", callback: () => void): void; public on(event: "streamEnded", callback: () => void): void; public on(event: "streamPaused", callback: () => void): void; public on(event: "streamReset", callback: () => void): void; public on(event: "streamSeek", callback: (time: number) => void): void; public on(event: "volumeChange", callback: (vol: number) => void): void; public on(event: "error", callback: (code: number, message: string) => void): void; public deleteMeta(key: string): void; public deleteMeta<K extends shared.ExtractStringKeys<ICustomAudioMeta>>(key: K): void; public hasMeta(key: string): boolean; public hasMeta<K extends shared.ExtractStringKeys<ICustomAudioMeta>>(key: K): boolean; public getMeta<K extends string>(key: Exclude<K, keyof ICustomAudioMeta>): unknown; public getMeta<K extends shared.ExtractStringKeys<ICustomAudioMeta>>(key: K): ICustomAudioMeta[K] | undefined; /** @deprecated See {@link ICustomAudioMeta} */ public getMeta<V extends any>(key: string): V | undefined; public setMeta<K extends string>(key: K, value: shared.InterfaceValueByKey<ICustomAudioMeta, K>): void; public setMeta<K extends shared.ExtractStringKeys<ICustomAudioMeta>>(key: K, value: ICustomAudioMeta[K]): void; /** @deprecated See {@link ICustomAudioMeta} */ public setMeta<V extends any, K extends string = string>(key: K, value: shared.InterfaceValueByKey<ICustomAudioMeta, K, V>): void; public setMeta(values: shared.MetaValues<ICustomAudioMeta>): void; } export class AudioOutput extends BaseObject { protected constructor(); public static readonly all: readonly AudioOutput[]; public static readonly count: number; /** * Retrieves the audiooutput from the pool. * * @param id The id of the audiooutput. * @returns Entity if it was found, otherwise null. */ public static getByID(id: number): AudioOutput | null; public muted: boolean; public volume: number; public category: number; public filter: AudioFilter | null; } export class AudioOutputFrontend extends AudioOutput { public constructor(categoryHash?: number); } export class AudioOutputWorld extends AudioOutput { public constructor(pos: shared.IVector3, categoryHash?: number); public pos: shared.Vector3; } export class AudioOutputAttached extends AudioOutput { public constructor(entity: WorldObject, categoryHash?: number); public entity: WorldObject; } export class WorldObject extends BaseObject { /** * Object position */ public pos: shared.Vector3; /** * Object dimension. * * @remarks Check https://docs.altv.mp/articles/dimensions.html to understand how it works. * */ public dimension: number; } export class Checkpoint extends WorldObject { public checkpointType: shared.CheckpointType; public nextPos: shared.Vector3; public radius: number; public height: number; public color: shared.RGBA; public iconColor: shared.RGBA; constructor(type: shared.CheckpointType, pos: shared.IVector3, nextPos: shared.IVector3, radius: number, height: number, rgbColor: shared.RGBA, iconColor: shared.RGBA, streamingDistance: number); /** * Streaming range for the checkpoint */ public readonly streamingDistance: number; public static readonly all: readonly Checkpoint[]; public static readonly count: number; public readonly isStreamedIn: boolean; public visible: boolean; /** * Retrieves the checkpoint from the pool. * * @param id The id of the checkpoint. * @returns Entity if it was found, otherwise null. * */ public static getByID(id: number): Checkpoint | null; public static getByScriptID(scriptID: number): Checkpoint | null; public readonly scriptID: number; public isEntityIn(entity: Entity): boolean; public isPointIn(pos: shared.IVector3): boolean; public deleteMeta(key: string): void; public deleteMeta<K extends shared.ExtractStringKeys<ICustomCheckpointMeta>>(key: K): void; public hasMeta(key: string): boolean; public hasMeta<K extends shared.ExtractStringKeys<ICustomCheckpointMeta>>(key: K): boolean; public getMeta<K extends string>(key: Exclude<K, keyof ICustomCheckpointMeta>): unknown; public getMeta<K extends shared.ExtractStringKeys<ICustomCheckpointMeta>>(key: K): ICustomCheckpointMeta[K] | undefined; /** @deprecated See {@link ICustomCheckpointMeta} */ public getMeta<V extends any>(key: string): V | undefined; public setMeta<K extends string>(key: K, value: shared.InterfaceValueByKey<ICustomCheckpointMeta, K>): void; public setMeta<K extends shared.ExtractStringKeys<ICustomCheckpointMeta>>(key: K, value: ICustomCheckpointMeta[K]): void; /** @deprecated See {@link ICustomCheckpointMeta} */ public setMeta<V extends any, K extends string = string>(key: K, value: shared.InterfaceValueByKey<ICustomCheckpointMeta, K, V>): void; public setMeta(values: shared.MetaValues<ICustomCheckpointMeta>): void; } export class Entity extends WorldObject { /** * Array with all entities. * * @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 * ```js * const entities = alt.Entity.all; // Store it in a variable, so it doesn't create a copy of the array on each iteration * for(let i = 0; i < entities.length; i++) * { * alt.log(`${entities[i].id}`); // Logs the id of every entity * } * ``` */ public static readonly all: readonly Entity[]; /** Internal game id that can be used in native calls */ public readonly scriptID: number; /** * 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. */ public readonly netOwner: Player | null; /** * Returns whether the entity is spawned in the game world. * * @remarks This does the same thing as checking if the {@link scriptID} is 0. */ public readonly isSpawned: boolean; /** Hash of entity model */ public get model(): number; /** * Object position. * @remarks Setting this throws an error if the client is not the network owner of an entity */ public pos: shared.Vector3; /** * Entity rotation in radians * @remarks Setting this throws an error if the client is not the network owner of an entity */ public rot: shared.Vector3; public readonly visible: boolean; /** * Retrieves the entity from the pool. * * @param scriptID The script id of the entity. * @returns Entity if it was found, otherwise null. */ public static getByScriptID(scriptID: number): Entity | null; public setMeta<K extends string>(key: K, value: shared.InterfaceValueByKey<ICustomEntityMeta, K>): void; public setMeta<K extends shared.ExtractStringKeys<ICustomEntityMeta>>(key: K, value: ICustomEntityMeta[K]): void; /** @deprecated See {@link ICustomEntityMeta} */ public setMeta<V extends any, K extends string = string>(key: K, value: shared.InterfaceValueByKey<ICustomEntityMeta, K, V>): void; public setMeta(values: shared.MetaValues<ICustomEntityMeta>): void; public deleteMeta(key: string): void; public deleteMeta<K extends shared.ExtractStringKeys<ICustomEntityMeta>>(key: K): void; public getMeta<K extends string>(key: Exclude<K, keyof ICustomEntityMeta>): unknown; public getMeta<K extends shared.ExtractStringKeys<ICustomEntityMeta>>(key: K): ICustomEntityMeta[K] | undefined; /** @deprecated See {@link ICustomEntityMeta} */ public getMeta<V extends any>(key: string): V | undefined; public hasMeta(key: string): boolean; public hasMeta<K extends shared.ExtractStringKeys<ICustomEntityMeta>>(key: K): boolean; /** * Gets a value using the specified key. * * @param key The key of the value to get. * @returns Dynamic value associated with the specified key or undefined if no data is present. */ public getSyncedMeta<K extends string>(key: Exclude<K, keyof shared.ICustomEntitySyncedMeta>): unknown; public getSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomEntitySyncedMeta>>(key: K): shared.ICustomEntitySyncedMeta[K] | undefined; /** @deprecated See {@link "alt-shared".ICustomEntitySyncedMeta} */ public getSyncedMeta<V extends any>(key: string): V | undefined; /** * Determines whether contains the specified key. * * @param key The key of the value to locate. * @returns True if the meta table contains any data at the specified key or False if not */ public hasSyncedMeta(key: string): boolean; public hasSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomEntitySyncedMeta>>(key: K): boolean; public getSyncedMetaKeys(): readonly string[]; /** * Gets a value using the specified key. * * @param key The key of the value to get. * @returns Dynamic value associated with the specified key or undefined if no data is present. */ public getStreamSyncedMeta<K extends string>(key: Exclude<K, keyof shared.ICustomEntityStreamSyncedMeta>): unknown; public getStreamSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomEntityStreamSyncedMeta>>(key: K): shared.ICustomEntityStreamSyncedMeta[K] | undefined; /** @deprecated See {@link "alt-shared".ICustomEntityStreamSyncedMeta} */ public getStreamSyncedMeta<V extends any>(key: string): V | undefined; /** * Determines whether contains the specified key. * * @param key The key of the value to locate. * @returns True if the meta table contains any data at the specified key or False if not */ public hasStreamSyncedMeta(key: string): boolean; public hasStreamSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomEntityStreamSyncedMeta>>(key: K): boolean; public getStreamSyncedMetaKeys(): readonly string[]; public getSyncInfo(): ISyncInfo; public frozen: boolean; } export class Player extends Entity { /** * 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 * ```js * 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 * } * ``` */ public static readonly all: readonly Player[]; public static readonly count: number; /** * Array with all streamed in players. */ public static readonly streamedIn: readonly Player[]; /** * The local player instance. */ public static readonly local: LocalPlayer; /** Player talking state */ public readonly isTalking: boolean; /** Player talking volume */ public readonly micLevel: number; /** Player name */ public readonly name: string; /** Player's vehicle, null if player is not in any vehicle */ public readonly vehicle: Vehicle | LocalVehicle | null; public readonly isDead: boolean; /** * Current weapon components. */ public readonly currentWeaponComponents: readonly number[]; public hasWeaponComponent(weaponModel: string | number, component: string | number): boolean; /** * Tint index for currently equipped weapon. */ public readonly currentWeaponTintIndex: number; public getWeaponTintIndex(weaponModel: string | number): number; /** * Currently equipped weapon. */ public readonly currentWeapon: number; /** * Is the player currently jumping. */ //public readonly isJumping: boolean; /** * Is the player currently in ragdoll. */ public readonly isInRagdoll: 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 */ public readonly isAiming: boolean; /** * Is the player currently shooting with a weapon. */ //public readonly isShooting: boolean; /** * Is the player currently reloading their weapon. */ public readonly isReloading: boolean; public readonly isEnteringVehicle: boolean; public readonly isLeavingVehicle: boolean; public readonly isOnLadder: boolean; public readonly isInMelee: boolean; public readonly isInCover: boolean; public readonly isParachuting: boolean; /** * Current armour. */ public readonly armour: number; /** * Max available armour value. */ public readonly maxArmour: number; /** * Current player movement speed. */ public readonly moveSpeed: number; /** * Position the player is currently aiming at. */ public readonly aimPos: shared.Vector3; /** * Rotation of the head of the player. */ public readonly headRot: shared.Vector3; /** * 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). * */ public readonly seat: number; /** * The entity the player is aiming at. */ public readonly entityAimingAt: Entity | null; /** * The current aim offset of the player. */ public readonly entityAimOffset: shared.Vector3; /** * Is the flashlight of the player activated. */ public readonly flashlightActive: boolean; /** * Current health of the player. */ public readonly health: number; /** * Current max health of the player. */ public readonly maxHealth: number; /** * Retrieves the player from the pool. * * @param id The id of the player. * @returns Entity if it was found, otherwise null. */ public static getByID(id: number): Player | null; /** * Retrieves the player from the pool. * * @param scriptID The script id of the player. * @returns Entity if it was found, otherwise null. */ public static getByScriptID(scriptID: number): Player | null; /** * Gets the player with the given remote id */ public static getByRemoteID(id: number): Player | null; /** * Set & get the volume for 3D Voice. * * @remarks Value needs to be between 0-1. */ public spatialVolume: number; /** * Set & get the volume for 2D Voice. * * @remarks Value needs to be between 0-1. */ public nonSpatialVolume: number; /** * Has the player superjump enabled. */ //public readonly isSuperJumpEnabled: boolean; /** * Is the player currently crouching. */ public readonly isCrouching: boolean; /** * Is the player currently stealthy. */ public readonly isStealthy: boolean; /** * Forward speed of the player. */ public readonly forwardSpeed: number; /** * Strafe speed of the player. */ public readonly strafeSpeed: number; public filter: AudioFilter | null; public readonly taskData: string; // normal meta public setMeta<K extends string>(key: K, value: shared.InterfaceValueByKey<ICustomPlayerMeta, K>): void; public setMeta<K extends shared.ExtractStringKeys<ICustomPlayerMeta>>(key: K, value: ICustomPlayerMeta[K]): void; /** @deprecated See {@link ICustomPlayerMeta} */ public setMeta<V extends any, K extends string = string>(key: K, value: shared.InterfaceValueByKey<ICustomPlayerMeta, K, V>): void; public setMeta(values: shared.MetaValues<ICustomPlayerMeta>): void; public deleteMeta(key: string): void; public deleteMeta<K extends shared.ExtractStringKeys<ICustomPlayerMeta>>(key: K): void; public getMeta<K extends string>(key: Exclude<K, keyof ICustomPlayerMeta>): unknown; public getMeta<K extends shared.ExtractStringKeys<ICustomPlayerMeta>>(key: K): ICustomPlayerMeta[K] | undefined; /** @deprecated See {@link ICustomPlayerMeta} */ public getMeta<V extends any>(key: string): V | undefined; public hasMeta(key: string): boolean; public hasMeta<K extends shared.ExtractStringKeys<ICustomPlayerMeta>>(key: K): boolean; // synced meta public getSyncedMeta<K extends string>(key: Exclude<K, keyof shared.ICustomPlayerSyncedMeta>): unknown; public getSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomPlayerSyncedMeta>>(key: K): shared.ICustomPlayerSyncedMeta[K] | undefined; /** @deprecated See {@link "alt-shared".ICustomPlayerSyncedMeta} */ public getSyncedMeta<V extends any>(key: string): V | undefined; public hasSyncedMeta(key: string): boolean; public hasSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomPlayerSyncedMeta>>(key: K): boolean; // stream synced meta public getStreamSyncedMeta<K extends string>(key: Exclude<K, keyof shared.ICustomPlayerStreamSyncedMeta>): unknown; public getStreamSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomPlayerStreamSyncedMeta>>(key: K): shared.ICustomPlayerStreamSyncedMeta[K] | undefined; /** @deprecated See {@link "alt-shared".ICustomPlayerStreamSyncedMeta} */ public getStreamSyncedMeta<V extends any>(key: string): V | undefined; public hasStreamSyncedMeta(key: string): boolean; public hasStreamSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomPlayerStreamSyncedMeta>>(key: K): boolean; } export class LocalPlayer extends Player { public readonly dimension: number; public pos: shared.Vector3; public rot: shared.Vector3; /** * Ammo of the currently held weapon. * * @returns Total ammo of the currently held weapon. 0 if no weapon is equipped. */ public readonly currentAmmo: number; public readonly weapons: readonly shared.IWeapon[]; public readonly currentWeaponData: WeaponData | null; public getWeaponAmmo(hash: number): number; public getWeaponAmmo(weaponName: string): number; public getWeaponComponents(hash: number): readonly number[]; public getWeaponComponents(weaponName: string): readonly number[]; public hasWeapon(hash: number): boolean; public hasWeapon(weaponName: string): boolean; public stamina: number; public maxStamina: number; public deleteMeta(key: string): void; public deleteMeta<K extends shared.ExtractStringKeys<ICustomLocalPlayerMeta>>(key: K): void; public hasMeta(key: string): boolean; public hasMeta<K extends shared.ExtractStringKeys<ICustomLocalPlayerMeta>>(key: K): boolean; public getMeta<K extends string>(key: Exclude<K, keyof ICustomLocalPlayerMeta>): unknown; public getMeta<K extends shared.ExtractStringKeys<ICustomLocalPlayerMeta>>(key: K): ICustomLocalPlayerMeta[K] | undefined; /** @deprecated See {@link ICustomLocalPlayerMeta} */ public getMeta<V extends any>(key: string): V | undefined; public setMeta<K extends string>(key: K, value: shared.InterfaceValueByKey<ICustomLocalPlayerMeta, K>): void; public setMeta<K extends shared.ExtractStringKeys<ICustomLocalPlayerMeta>>(key: K, value: ICustomLocalPlayerMeta[K]): void; /** @deprecated See {@link ICustomLocalPlayerMeta} */ public setMeta<V extends any, K extends string = string>(key: K, value: shared.InterfaceValueByKey<ICustomLocalPlayerMeta, K, V>): void; public setMeta(values: shared.MetaValues<ICustomLocalPlayerMeta>): void; } export class Vehicle extends Entity { /** * Array with all vehicles. * * @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 * ```js * const vehicles = alt.Vehicle.all; // Store it in a variable, so it doesn't create a copy of the array on each iteration * for(let i = 0; i < vehicles.length; i++) * { * alt.log(`${vehicles[i].model}`); // Logs the model of every vehicle * } * ``` */ public static readonly all: readonly Vehicle[]; public static readonly count: number; /** * Array with all streamed in vehicles. */ public static readonly streamedIn: readonly Vehicle[]; /** * Vehicle gear. * * @returns A number indicating actual gear. */ public gear: number; /** * Vehicle max gear. */ public readonly maxGear: number; /** * Vehicle handling, which affects how vehicle responds and reacts to the inputs of a driver. */ public handling: IVehicleHandling; /** * Vehicle indicator lights. */ public indicatorLights: VehicleIndicatorLights; /** * Vehicle RPM. * * @returns Normalised value on a scale of [0, 1]. */ public rpm: number; /** * Vehicle wheels speed. */ public readonly speed: number; /** * Vehicle speed vector. */ public readonly speedVector: shared.Vector3; /** * Vehicle seat count. */ public readonly seatCount: number; /** * Vehicle velocity vector. */ //public readonly velocity: shared.Vector3; /** * Vehicle wheels count. */ public readonly wheelsCount: number; /** * Is the vehicle destroyed. */ //public readonly isDestroyed: boolean; /** * Available modkits for the vehicle. */ //public readonly modKitsCount: number; /** * Current vehicle modkit. */ //public readonly modKit: number; /** * Vehicle primary color. */ //public readonly primaryColor: number; /** * Custom (RGB) vehicle primary color. */ //public readonly customPrimaryColor: shared.RGBA; /** * Vehicle secondary color. */ //public readonly secondaryColor: number; /** * Custom (RGB) vehicle secondary color. */ //public readonly customSecondaryColor: shared.RGBA; /** * Vehicle pearl color. */ //public readonly pearlColor: number; /** * Vehicle wheel color. */ //public readonly wheelColor: number; /** * Vehicle interior color. */ //public readonly interiorColor: number; /** * Vehicle dashboard color. */ //public readonly dashboardColor: number; /** * Vehicle tire smoke color. */ //public readonly tireSmokeColor: number; /** * Vehicle wheel type. */ //public readonly wheelType: number; /** * Vehicle front wheels variation. */ //public readonly frontWheels: number; /** * Vehicle rear wheels variation. */ //public readonly rearWheels: number; /** * Are custom tires active. */ //public readonly customTires: boolean; /** * Vehicle darkness. */ //public readonly darkness: number; /** * Vehicle number plate type index. */ //public readonly numberPlateIndex: number; /** * Vehicle number plate text. */ //public readonly numberPlateText: string; /** * Vehicle window tint. */ //public readonly windowTint: number; /** * Vehicle dirt level. */ //public readonly dirtLevel: number; /** * Vehicle neon. */ //public readonly neon: IVehicleNeon; /** * Vehicle neon color. */ //public readonly neonColor: shared.RGBA; /** * Vehicle livery. */ //public readonly livery: number; /** * Vehicle roof livery. */ //public readonly roofLivery: number; /** * Vehicle engine state. */ public readonly engineOn: boolean; public getWheelSurfaceMaterial(wheel: number): number; /** * Ve