): 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.
*
*
* @param player The given player that will be set as new network owner.
* @param disableMigration Pass true to disable migration, false to keep it enabled. If not specified, it defaults to "false".
*/
public setNetOwner(player: Player, 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.
*
*
* @param disableMigration Pass true to disable migration, false to keep it enabled. If not specified, it defaults to "false".
*/
public resetNetOwner(disableMigration?: boolean): void;
/**
* Attaches this entity to another entity.
*
* @param entity Target entity.
* @param entityBone Target bone id or name.
* @param ownBone Origin bone id or name.
* @param pos Position offset.
* @param rot Rotation - needs to be in radians.
* @param enableCollisions If true the attached entity has a collision.
* @param noFixedRotation 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
*/
public attachTo(entity: Entity, entityBone: number | string, ownBone: number | string, pos: shared.IVector3, rot: shared.IVector3, enableCollisions: boolean, noFixedRotation: boolean): void;
/**
* Detaches this entity if attached to another entity.
*/
public detach(): void;
public frozen: boolean;
public collision: boolean;
public streamingDistance: number;
public readonly timestamp: number;
}
export class Player extends Entity {
/**
* 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
* ```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 readonly streamedEntities: readonly { entity: Entity; distance: number }[];
public static readonly count: number;
public armour: number;
public currentWeapon: number;
public readonly weapons: readonly shared.IWeapon[];
public readonly currentWeaponComponents: readonly number[];
public readonly currentWeaponTintIndex: number;
public readonly entityAimOffset: shared.Vector3;
public readonly entityAimingAt: Entity | null;
public readonly flashlightActive: boolean;
public readonly moveSpeed: number;
public readonly isInRagdoll: boolean;
public readonly isAiming: boolean;
public readonly isDead: boolean;
//public readonly isShooting: boolean;
//public readonly isJumping: boolean;
/**
* The player's state of weapon reloading.
*/
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;
public readonly isOnVehicle: boolean;
public readonly isInWater: boolean;
/**
* Position the player is currently aiming at.
*
* @remarks Will return {@link Vector3.zero} if the player is aiming against a entity.
*/
public readonly aimPos: shared.Vector3;
public readonly headRot: shared.Vector3;
public health: number;
public readonly ip: string;
public maxArmour: number;
public maxHealth: number;
public readonly name: string;
public readonly ping: number;
public readonly cloudID: string;
public readonly cloudAuthResult: CloudAuthResult;
/**
* 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;
public readonly vehicle: Vehicle | null;
public invincible: boolean;
public readonly isSuperJumpEnabled: boolean;
public readonly isCrouching: boolean;
public readonly isStealthy: boolean;
public readonly isSpawned: boolean;
public readonly socialID: string;
public readonly socialClubName: string;
public readonly hwid3: string;
public readonly hwidHash: string;
public readonly hwidExHash: string;
public readonly authToken: string;
public readonly discordID: string;
public readonly currentAnimationDict: number;
public readonly currentAnimationName: number;
public readonly forwardSpeed: number;
public readonly strafeSpeed: number;
public readonly currentInterior: number;
public lastDamagedBodyPart: number;
/**
* Send names of all players on server to this player if they are not already sent (value is not set to `true`).
*/
public sendNames: boolean;
/**
* Retrieves the player from the pool.
*
* @param id The id of the player.
* @returns Player if it was found, otherwise null.
*/
public static getByID(id: number): Player | null;
/**
* Emits specified event to client.
*
* @param eventName Name of the event.
* @param args Rest parameters for emit to send.
*/
public emit(eventName: K, ...args: Parameters): void;
public emit(eventName: Exclude, ...args: any[]): void;
/**
* Emits specified event to client, but faster as {@link Player.emit}.
*
* @param eventName Name of the event.
* @param args Rest parameters for emit to send.
*/
public emitRaw(eventName: K, ...args: Parameters): void;
public emitRaw(eventName: Exclude, ...args: any[]): void;
/**
* Calls a client sided RPC with the specified arguments.
*
* @param rpcName Name of the RPC
* @param ...args Arguments to pass to the RPC
*
*/
public emitRpc(rpcName: K, ...args: Parameters): Promise>;
public emitRpc(rpcName: Exclude, ...args: any[]): Promise;
public addWeaponComponent(weaponHash: number, component: number): void;
public hasWeaponComponent(weaponModel: string | number, component: string | number): boolean;
/**
* Removes the visible blood on the player body.
*/
public clearBloodDamage(): void;
public getBloodDamageBase64(): string;
public setBloodDamageBase64(base64: string): void;
/**
* Gives the specified weapon to the player.
*
* @remarks Amount of given ammo is shared between all weapons
* with the same [ammo type](https://gist.github.com/root-cause/faf41f59f7a6d818b7db0b839bd147c1).
* 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
* ```js
* 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
* ```
*
* @param weaponModel The model of the weapon.
* @param ammo Amount of ammo to spawn the weapon with. See remarks for more information.
* @param equipNow Should the weapon be equipped immediately.
*/
public giveWeapon(weaponModel: string | number, ammo: number, equipNow: boolean): void;
public hasWeapon(weaponModel: string | number): boolean;
/**
* Forcefully disconnects the player with a reason message.
*
* @param reason The reason that will display to the player on the disconnect screen. If not specified, it defaults to "KICKED_OUT".
*/
public kick(reason?: string): void;
/**
* Removes every weapon from the player.
*/
public removeAllWeapons(removeAllAmmo?: boolean): void;
/**
* Removes the specified weapon from the player.
*
* @param weaponHash Hash of the weapon.
*/
public removeWeapon(weaponHash: number): void;
/**
* Removes the specified weapon component from the specified weapon.
*
* @param weaponHash Hash of the weapon.
* @param component Hash of the weapon component.
*/
public removeWeaponComponent(weaponHash: number, component: number): void;
public setDateTime(day: DateTimeDay, month: DateTimeMonth, year: number, hour: DateTimeHour, minute: DateTimeMinute, second: DateTimeSecond): void;
public setWeaponTintIndex(weaponHash: number, tintIndex: number): void;
public setWeather(weatherType: WeatherType): void;
public setWeather(weatherType: T): void;
/**
* Spawns the player in the world.
*
* @remarks The player has to have a model set before being spawned.
*
* @param x The x position where the player gets spawned.
* @param y The y position where the player gets spawned.
* @param z The z position where the player gets spawned.
* @param delay The delay at which the player gets spawned after calling this function. Defaults to 0.
*/
public spawn(x: number, y: number, z: number, delay?: number): void;
/**
* Spawns the player in the world.
*
* @remarks The player has to have a model set before being spawned.
*
* @param pos The position where the player gets spawned.
* @param delay The delay at which the player gets spawned after calling this function. Defaults to 0.
*/
public spawn(pos: shared.IVector3, delay?: number): void;
/**
* Sets the model and spawns the player in the world.
*
* @param model The model to be set to the player before spawning.
* @param pos The position where the player gets spawned.
*/
public spawn(model: string | number, pos: shared.IVector3): void;
public despawn(): void;
/**
* Gets the specified clothing component.
*
* @example
* ```js
* let cloth = player.getClothes(1); // Gets the currently equipped mask
* alt.log(cloth.drawable); // Logs the drawable of the currently equipped mask
* ```
*
* @param component Component id of the clothing.
*/
public getClothes(component: number): ICloth;
/**
* Gets the specified dlc clothing component.
*
* @example
* ```js
* let cloth = player.getDlcClothes(1); // Gets the currently equipped mask
* alt.log(cloth.drawable); // Logs the drawable of the currently equipped mask
* ```
*
* @param component Component id of the clothing.
*/
public getDlcClothes(component: number): IDlcCloth;
public clearClothes(component: number): void;
/**
* Sets the specified clothing component.
*
* @remarks The dlc hash is only required when setting dlc clothing.
* @example
* ```js
* player.setClothes(1, 14, 0); // Sets the players mask to a blue hockey mask
* ```
*
* @param component Component id of the clothing.
* @param drawable Drawable id of the clothing.
* @param texture Texture id of the clothing.
* @param palette Palette of the clothing.
*/
public setClothes(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
* ```js
* player.setDlcClothes(alt.hash('dlcname'), 1, 14, 0);
* ```
*
* @param dlc Dlc hash of the clothing.
* @param component Component id of the clothing.
* @param drawable Drawable id of the clothing.
* @param texture Texture id of the clothing.
* @param palette Palette of the clothing.
*/
public setDlcClothes(dlc: number, component: number, drawable: number, texture: number, palette?: number): boolean;
/**
* Gets the specified prop component.
*
* @example
* ```js
* 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
* ```
*
* @param component Component id of the prop.
*/
public getProp(component: number): IProp;
/**
* Gets the specified dlc prop component.
*
* @example
* ```js
* 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
* ```
*
* @param component Component id of the prop.
*/
public getDlcProp(component: number): IDlcProp;
/**
* Sets the specified prop component.
*
* @example
* ```js
* player.setProp(0, 13, 0); // sets the players hat prop to a blue cowboy hat
* ```
*
* @param component Component id of the prop.
* @param drawable Drawable id of the prop.
* @param texture Texture id of the prop.
*/
public setProp(component: number, drawable: number, texture: number): boolean;
/**
* Sets the specified dlc prop component.
*
* @example
* ```js
* player.setDlcProp(alt.hash('dlcname'), 0, 13, 0);
* ```
*
* @param dlc Dlc hash of the prop.
* @param component Component id of the prop.
* @param drawable Drawable id of the prop.
* @param texture Texture id of the prop.
*/
public setDlcProp(dlc: number, component: number, drawable: number, texture: number): boolean;
/**
* Removes a specified prop component.
*
* @example
* ```js
* player.clearProp(0); // removes the player hat prop
* ```
*
* @param component Component id of the prop.
*/
public clearProp(component: number): void;
/**
* Checks whether the given entity is in the stream range of the player.
*
* @example
* ```js
* 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
* ```
*/
public isEntityInStreamRange(entity: Entity): boolean;
/**
* Set the player into a vehicle on specific seat.
*
* @remarks The seat indexes start with 1 (driver seat).
*/
public setIntoVehicle(vehicle: Vehicle, seat: number): void;
/**
* Plays ambient speech.
*
* @Remarks See https://github.com/DurtyFree/gta-v-data-dumps/blob/master/speeches.json for a full list of speeches.
*
* @param speechName Name of the speach.
* @param speechParam Param of the speach.
* @param speechDictHash Hash of the speach dict.
*/
public playAmbientSpeech(speechName: string, speechParam: string, speechDictHash: number): void;
public setHeadOverlay(overlayID: number, index: number, opacity: number): boolean;
public removeHeadOverlay(overlayID: number): boolean;
public setHeadOverlayColor(overlayID: number, colorType: number, colorIndex: number, secondColorIndex: number): boolean;
public getHeadOverlay(overlayID: number): IHeadOverlay;
public setFaceFeature(index: number, scale: number): boolean;
public getFaceFeatureScale(index: number): number;
public removeFaceFeature(index: number): boolean;
public setHeadBlendPaletteColor(id: number, red: number, green: number, blue: number): boolean;
public getHeadBlendPaletteColor(id: number): shared.RGBA;
public removeHeadBlendPaletteColor(): void;
public setHeadBlendData(shapeFirstID: number, shapeSecondID: number, shapeThirdID: number, skinFirstID: number, skinSecondID: number, skinThirdID: number, shapeMix: number, skinMix: number, thirdMix: number): void;
public removeHeadBlendData(): void;
public getHeadBlendData(): IHeadBlendData;
public setEyeColor(eyeColor: number): boolean;
public getEyeColor(): number;
public setHairColor(hairColor: number): void;
public getHairColor(): number;
public setHairHighlightColor(hairHighlightColor: number): void;
public getHairHighlightColor(): number;
public addDecoration(collection: string | number, overlay: string | number, count?: number): void;
public removeDecoration(collection: string | number, overlay: string | number): void;
public clearDecorations(): void;
public getDecorations(): readonly IDecoration[];
public playAnimation(animDict: string, animName: string, blendInSpeed?: number, blendOutSpeed?: number, duration?: number, flags?: number, playbackRate?: number, lockX?: boolean, lockY?: boolean, lockZ?: boolean): void;
public clearTasks(): void;
public playScenario(name: string): void;
public getAmmo(ammoHash: number | string): number;
public setAmmo(ammoHash: number | string, ammo: number): void;
public getWeaponAmmo(weaponHash: number | string): number;
public setWeaponAmmo(weaponHash: number | string, ammo: number): void;
public getAmmoSpecialType(ammoHash: number | string): AmmoSpecialType;
public setAmmoSpecialType(ammoHash: number | string, ammoSpecialType: AmmoSpecialType): void;
public getAmmoFlags(ammoHash: number | string): IAmmoFlags;
public setAmmoFlags(ammoHash: number | string, infiniteAmmo: boolean, addSmokeOnExplosion: boolean, fuse: boolean, fixedAfterExplosion: boolean): void;
public getAmmoMax(ammoHash: number | string): number;
public setAmmoMax(ammoHash: number | string, ammoMax: number): void;
public getAmmoMax50(ammoHash: number | string): number;
public setAmmoMax50(ammoHash: number | string, ammoMax: number): void;
public getAmmoMax100(ammoHash: number | string): number;
public setAmmoMax100(ammoHash: number | string, ammoMax: number): void;
public netOwnershipDisabled: boolean;
// local meta
/**
* Stores the given value with the specified key.
*
* @param key The key of the value to store.
* @param value The value to store.
*/
public setLocalMeta(key: K, value: shared.InterfaceValueByKey): void;
public setLocalMeta>(key: K, value: shared.ICustomPlayerLocalMeta[K]): void;
/** @deprecated See {@link "alt-shared".ICustomPlayerLocalMeta} */
public setLocalMeta(key: K, value: shared.InterfaceValueByKey): void;
public setLocalMeta(values: shared.MetaValues): void;
public deleteLocalMeta(key: string): void;
public deleteLocalMeta>(key: K): void;
/**
* 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 getLocalMeta(key: Exclude): unknown;
public getLocalMeta>(key: K): shared.ICustomPlayerLocalMeta[K] | undefined;
/** @deprecated See {@link "alt-shared".ICustomPlayerLocalMeta} */
public getLocalMeta(key: string): V | undefined;
public hasLocalMeta(key: string): boolean;
public hasLocalMeta>(key: K): boolean;
public getLocalMetaKeys(): readonly string[];
// normal meta
public setMeta(key: K, value: shared.InterfaceValueByKey): void;
public setMeta>(key: K, value: ICustomPlayerMeta[K]): void;
/** @deprecated See {@link ICustomPlayerMeta} */
public setMeta(key: K, value: shared.InterfaceValueByKey): void;
public setMeta(values: shared.MetaValues): void;
public deleteMeta(key: string): void;
public deleteMeta>(key: K): void;
public getMeta(key: Exclude): unknown;
public getMeta>(key: K): ICustomPlayerMeta[K] | undefined;
/** @deprecated See {@link ICustomPlayerMeta} */
public getMeta(key: string): V | undefined;
public hasMeta(key: string): boolean;
public hasMeta>(key: K): boolean;
// synced meta
public setSyncedMeta(key: K, value: shared.InterfaceValueByKey): void;
public setSyncedMeta>(key: K, value: shared.ICustomPlayerSyncedMeta[K]): void;
/** @deprecated See {@link "alt-shared".ICustomPlayerSyncedMeta} */
public setSyncedMeta(key: K, value: shared.InterfaceValueByKey): void;
public setSyncedMeta(values: shared.MetaValues): void;
public deleteSyncedMeta(key: string): void;
public deleteSyncedMeta>(key: K): void;
public getSyncedMeta(key: Exclude): unknown;
public getSyncedMeta>(key: K): shared.ICustomPlayerSyncedMeta[K] | undefined;
/** @deprecated See {@link "alt-shared".ICustomPlayerSyncedMeta} */
public getSyncedMeta(key: string): V | undefined;
public hasSyncedMeta(key: string): boolean;
public hasSyncedMeta>(key: K): boolean;
// stream synced meta
public setStreamSyncedMeta(key: K, value: shared.InterfaceValueByKey): void;
public setStreamSyncedMeta>(key: K, value: shared.ICustomPlayerStreamSyncedMeta[K]): void;
/** @deprecated See {@link "alt-shared".ICustomPlayerStreamSyncedMeta} */
public setStreamSyncedMeta(key: K, value: shared.InterfaceValueByKey): void;
public setStreamSyncedMeta(values: shared.MetaValues): void;
public deleteStreamSyncedMeta(key: string): void;
public deleteStreamSyncedMeta>(key: K): void;
public getStreamSyncedMeta(key: Exclude): unknown;
public getStreamSyncedMeta>(key: K): shared.ICustomPlayerStreamSyncedMeta[K] | undefined;
/** @deprecated See {@link "alt-shared".ICustomPlayerStreamSyncedMeta} */
public getStreamSyncedMeta(key: string): V | undefined;
public hasStreamSyncedMeta(key: string): boolean;
public hasStreamSyncedMeta>(key: K): boolean;
}
/**
* A vehicle is an extension of the Entity class.
*
* @example
* ```js
* // Get the vehicle a player is driving.
* const vehicle = alt.Vehicle.all.find(veh => veh.driver && veh.driver.name === 'Stuyk');
* if (!vehicle) {
* console.log('Stuyk is not driving a vehicle');
* } else {
* console.log('Stuyk is driving a vehicle.')
* const player = vehicle.driver;
* }
* ```
*
* @export
* @class Vehicle
* @extends {Entity}
*/
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;
/**
* Get the entity model hash.
*
* @example
* ```js
* const comparisonHash = alt.hash('infernus');
* if (comparisonHash === someVehicle.model) {
* console.log('This vehicle is an infernus.');
* } else {
* console.log('This vehicle is not an infernus.');
* }
* ```
* @remarks Vehicle doesn't provide a setter.
*/
public get model(): number;
/**
* Gets or sets the active radio station.
*
* @example
* ```js
* const someVehicle = alt.Vehicle.all[0];
* const stationNumber = someVehicle.activeRadioStation;
* console.log(`Current Station: ${stationNumber}`);
*
* someVehicle.activeRadioStation = 255;
* console.log(`Vehicle radio station was turned off.`);
* ```
*/
public activeRadioStation: RadioStation;
/**
* Gets or sets the additional body health.
*/
public bodyAdditionalHealth: number;
/**
* Gets or sets the body health.
*/
public bodyHealth: number;
/**
* Gets or sets the custom primary color as a RGBA type.
*
* @example
* ```js
* const someVehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
* someVehicle.customPrimaryColor = new alt.RGBA(255, 0, 0);
* console.log(`Vehicle custom primary color was set to red`);
* ```
*/
public customPrimaryColor: shared.RGBA;
/**
* Gets or sets the custom secondary color as a RGBA type.
* @example
* ```js
* const someVehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
* someVehicle.customSecondaryColor = new alt.RGBA(255, 0, 0);
* console.log(`Vehicle custom secondary color was set to red`);
* ```
*/
public customSecondaryColor: shared.RGBA;
/**
* Gets or sets if the vehicle instance has custom tires.
*/
public customTires: boolean;
/**
* Applies some decoration effects to the vehicle (e.g.: It makes the hydra looking rusty or applies snow to the front bumper of `policeold1`). Does not work on every vehicle model.
*
* @example
* ```js
* const someVehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
* someVehicle.darkness = 500;
* ```
*/
public darkness: number;
/**
* Gets or sets the dashboard color of the vehicle.
*
* Dash board colors range from 0 to 159.
*
* @example
* ```js
* const someVehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
* someVehicle.dashboardColor = 139;
* ```
*/
public dashboardColor: number;
/**
* Gets the current state of the daylights.
*
* @example
* ```js
* const someVehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
* if (someVehicle.daylightOn) {
* console.log('Vehicle daylights are on');
* } else {
* console.log('Vehicle daylights are off');
* }
* ```
*/
public readonly daylightOn: boolean;
/**
* Gets if a vehicle is destroyed.
*
* Destroyed is set to true when specific game activities cause the engine to stop.
* Explosions, being underwater, crashing too much, etc.
*
* @example
* ```js
* const someVehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
*
* if (someVehicle.destroyed) {
* console.log(`The elegy has been destroyed.`);
* }
* ```
*
*/
public readonly destroyed: boolean;
/**
* Gets or sets the dirt level of the vehicle.
*/
public dirtLevel: number;
/**
* Gets the current driver of the vehicle. It returns null, if there is no driver.
*
* @example
* ```js
* const someVehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
* const driver = someVehicle.driver;
*
* if (driver) {
* console.log(`There is currently a player driving this car. ${driver.name}`);
* }
* ```
*
*/
public readonly driver: Player | null;
/**
* Gets all passengers of the vehicle including the driver itself.
*
* @example
* ```js
* const someVehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
* const passengers = someVehicle.passengers;
*
* for (const [seat, player] of Object.entries(passengers)) {
* alt.log(`Seat: ${seat} - Player: ${player.name}`);
* }
* ```
*
*/
public readonly passengers: IVehiclePassenger;
/**
* Gets or sets the current engine health.
*
* Default maximum engine health is 1000.
* The `vehicle.repair()` function should be used to repair a vehicle if the engine health is less than or equal to zero.
*
* This example demonstrates that when you drive through a ColShape it will repair the vehicle.
*
* @example
* ```js
* const someColShape = new alt.ColshapeCircle(-1295.9208984375, 86.0835189819336, 2);
* someColShape.repairVehicles = true;
*
* alt.on('entityEnterColshape', (colshape, entity) => {
* // Check if the entity is a vehicle or not.
* if (!(entity instanceof alt.Vehicle)) {
* return;
* }
*
* // Check if it's the right colshape to do this.
* if (!colshape.repairVehicles) {
* return;
* }
*
* if (entity.destroyed) {
* entity.repair();
* console.log('Repaired Destroyed Vehicle');
* return;
* }
*
* entity.engineHealth = 1000;
* console.log('Repaired Vehicle')
* });
* ```
*
*/
public engineHealth: number;
/**
* Gets or sets the engine state of the vehicle.
*
* The functionality of the vehicle engine can be triggered on either client-side or server-side. If you want to trigger the engine on client-side use native.setVehicleEngineOn.
*
* @example
* ```js
* const vehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
* vehicle.engineOn = true;
* ```
*/
public engineOn: boolean;
/**
* Gets if a flamethrower of a vehicle is active on vehicle models like `cerberus`.
*/
public readonly flamethrowerActive: boolean;
/**
* Gets if the handbrake of a car is active.
*/
public readonly handbrakeActive: boolean;
/**
* Gets if the car has armored windows.
*/
public readonly hasArmoredWindows: boolean;
/**
* Gets or sets the headlight color of a vehicle.
*/
public headlightColor: number;
/**
* Gets or sets the interior color of a vehicle.
*/
public interiorColor: number;
/**
* Gets or sets the lights intensity and distance of a vehicle.
*/
public lightsMultiplier: number;
/**
* Gets or sets the livery of a vehicle.
*/
public livery: number;
/**
* Gets or sets the lock state of a vehicle.
*/
public lockState: shared.VehicleLockState;
/**
* Enables or disables the manual engine control.
*/
public manualEngineControl: boolean;
/**
* Gets or sets the current mod kit of a vehicle.
*/
public modKit: number;
/**
* Gets the maximum amount of vehicle mod kits available.
*/
public readonly modKitsCount: number;
/**
* Enables or disables a neon light on a specific position.
*/
public neon: IVehicleNeon;
/**
* Gets or sets the color of the neon lights.
*/
public neonColor: shared.RGBA;
/**
* Gets the current state of the nightlights.
*/
public readonly nightlightOn: boolean;
/**
* Gets or sets the current number plate style.
*/
public numberPlateIndex: NumberPlateStyle;
/**
* Gets or sets the current text displayed on the number plate.
*/
public numberPlateText: string;
/**
* Gets or sets the pearl color of a vehicle.
*/
public pearlColor: number;
/**
* Gets or sets the current health amount of the petrol tank.
*/
public petrolTankHealth: number;
/**
* Gets or sets the current primary color of a vehicle.
*/
public primaryColor: number;
/**
* Gets how often a vehicle got repaired.
*/
public readonly repairsCount: number;
/**
* Gets or sets the roof livery of a vehicle.
*/
public roofLivery: number;
/**
* Gets or sets the roof state of a vehicle (closed or open).
*
* @deprecated Use {@link roofClosed} instead.
*/
public roofState: boolean;
/**
* Opens or closes the vehicle roof (if vehicle has this feature, otherwise it is always `true`).
*
* @example
* ```js
* const surano = new alt.Vehicle('surano', 0, 0, 72, 0, 0, 0);
* surano.roofClosed = false; // Hides the roof of the car
* ```
*/
public roofClosed: boolean;
/**
* Gets or sets the current secondary color.
*/
public secondaryColor: number;
/**
* Gets or sets the siren state of a vehicle.
*/
public sirenActive: boolean;
/**
* Gets or sets the color of the tire smoke.
*/
public tireSmokeColor: shared.RGBA;
/**
* Gets or sets the wheel color.
*/
public wheelColor: number;
/**
* Gets the amount of wheels of a vehicle.
*/
public readonly wheelsCount: number;
/**
* Gets the wheel type.
*/
public readonly wheelType: number;
/**
* Gets the type of the front wheels.
*/
public readonly frontWheels: number;
/**
* Gets the type of the rear wheels.
*/
public readonly rearWheels: number;
/**
* Gets or sets the window tint of a vehicle.
*/
public windowTint: WindowTint;
/**
* Gets a vehicle that is attached to the vehicle instance.
*/
public readonly attached: Vehicle | null;
/**
* Gets a vehicle where the vehicle is attached to.
*/
public readonly attachedTo: Vehicle | null;
/**
* Gets the velocity vector of a vehicle.
*/
public readonly velocity: shared.Vector3;
/**
* Gets or sets the drift mode state of the vehicle.
*/
public driftModeEnabled: boolean;
/**
* Gets or sets the vehicles rotation with a quaternion.
*/
public quaternion: shared.Quaternion;
/**
* Indicates whether the object is static, meaning it has no network owner and server retains full control over the entity's state.
*/
public isStaticEntity: boolean;
constructor(model: string | number, x: number, y: number, z: number, rx: number, ry: number, rz: number, streamingDistance?: number, isStaticEntity?: boolean);
constructor(model: string | number, pos: shared.IVector3, rot: shared.IVector3, streamingDistance?: number, isStaticEntity?: boolean);
/**
* Retrieves the vehicle from the pool.
*
* @param id The id of the vehicle.
* @returns Vehicle if it was found, otherwise null.
*/
public static getByID(id: number): Vehicle | null;
/**
* Returns if a specific wheel has a tire.
*
* @param wheelId The specific wheel based on the id
* @returns True when the wheel has a tire, otherwise false.
*/
public doesWheelHasTire(wheelId: number): boolean;
/**
* Returns the appearance of a vehicle as a base64 string.
*
* @returns A base64 string.
*/
public getAppearanceDataBase64(): string;
/**
* Returns the health of a specific armored window.
*
* @param windowId The window id.
* @returns The amount of health.
*/
public getArmoredWindowHealth(windowId: number): number;
/**
* Returns the amount of shoots that a specific armoured window received.
*
* @param windowId The window id.
* @returns The amount of shoots that a window received.
*/
public getArmoredWindowShootCount(windowId: number): number;
/**
* Returns the damage level of a specific bumper.
*
* @param bumperId The id of a bumper.
* @returns The damage level of a bumper.
*/
public getBumperDamageLevel(bumperId: VehicleBumper): VehicleBumperDamage;
public getBumperDamageLevel(bumperId: T): V;
/**
* Returns the damage status of a vehicle as a base64 string.
*
* @returns A base64 string of the damage status.
*/
public getDamageStatusBase64(): string;
/**
* Returns the state of a specific door.
*
* @param doorId The id of the door.
* @returns The state of the door.
*/
public getDoorState(doorId: VehicleDoor): VehicleDoorState;
public getDoorState(doorId: T): V;
/**
* Returns the state of a specific extra of a vehicle.
*
* @remarks Extras are not available on every vehicle model.
*
* @param extraId The id of the extra.
* @returns True when the extra is enabled, otherwise false.
*/
public getExtra(extraId: number): boolean;
/**
* Returns the game state data of a vehicle as a base64 string.
*
* @returns A base64 string of the game state data.
*/
public getGamestateDataBase64(): string;
/**
* Returns the health data of a vehicle as a base64 string.
*
* @returns A base64 string of the health data.
*/
public getHealthDataBase64(): string;
/**
* Returns the mod value for a specific mod type.
*
* @param modType The id of the mod type.
* @returns The value of the mod type.
*/
public getMod(modType: VehicleModType): number;
public getMod(modType: T): number;
/**
* Returns the amount of possible mod values for a specific mod type.
*
* @param modType The id of the mod type.
* @returns The amount of possible mod values of a mod type.
*/
public getModsCount(modType: VehicleModType): number;
public getModsCount(modType: T): number;
/**
* Returns the amount of bullet holes of a vehicle part.
*
* @param partId The id of a vehicle part.
* @returns The amount of bullet holes of a vehicle part.
*/
public getPartBulletHoles(partId: VehiclePart): number;
public getPartBulletHoles(partId: T): number;
/**
* Returns the damage level of a vehicle part.
*
* @param partId The id of a vehicle part.
* @returns The damage level of a vehicle part.
*/
public getPartDamageLevel(partId: VehiclePart): VehiclePartDamage;
public getPartDamageLevel(partId: T): V;
/**
* Returns the script data of a vehicle as a base64 string.
*
* @returns A base64 string of the script data.
*/
public getScriptDataBase64(): string;
/**
* Returns the health of a specific wheel.
*
* @param wheelId The id of the wheel.
* @returns The amount of health of a specific wheel.
*/
public getWheelHealth(wheelId: number): number;
/**
* Returns if a specific light is damaged.
*
* @param lightId The id of the light.
* @returns True if the light is damaged, otherwise false.
*/
public isLightDamaged(lightId: number): boolean;
/**
* Returns if a specific special light is damaged.
*
* @param specialLightId The id of the special light.
* @returns True if the special light is damaged, otherwise false.
*/
public isSpecialLightDamaged(specialLightId: number): boolean;
/**
* Returns if a specific wheel is burst.
*
* @param wheelId The id of the wheel.
* @returns True if the wheel is burst, otherwise false.
*/
public isWheelBurst(wheelId: number): boolean;
/**
* Returns if a specific wheel is detached.
*
* @param wheelId The id of the wheel.
* @returns True if the wheel is detached, otherwise false.
*/
public isWheelDetached(wheelId: number): boolean;
/**
* Returns if a specific wheel is on fire.
*
* @param wheelId The id of the wheel.
* @returns True if the wheel is on fire, otherwise false.
*/
public isWheelOnFire(wheelId: number): boolean;
/**
* Returns if a specific window is damaged.
*
* @param windowId The id of the window.
* @returns True if the window is damaged, otherwise false.
*/
public isWindowDamaged(windowId: number): boolean;
/**
* Returns if a specific window is open.
*
* @param windowId The id of the window.
* @returns True if the window is open, otherwise false.
*/
public isWindowOpened(windowId: number): boolean;
/**
* Repairs the vehicle.
*
* @remarks At present this function is **unstable**,
* consider recreating the vehicle instead.
* * https://github.com/altmp/altv-issues/issues/1748
* * https://github.com/altmp/altv-issues/issues/1184
* * https://github.com/altmp/altv-issues/issues/1445
* * https://github.com/altmp/altv-issues/issues/1426
*/
public repair(): void;
/**
* Sets the appearance of a vehicle with a base64 string.
*
* @param data The base64 string of the appearance data.
*/
public setAppearanceDataBase64(data: string): void;
/**
* Sets the health of a specific armored window.
*
* @param windowId The id of the window.
* @param health The amount of health.
*/
public setArmoredWindowHealth(windowId: number, health: number): void;
/**
* Sets the shoot count of a specific armoured window.
*
* @param windowId The id of the window.
* @param count The amount of shoots.
*/
public setArmoredWindowShootCount(windowId: number, count: number): void;
/**
* Sets the damage level of a specific bumper.
*
* @param bumperId The id of the bumper.
* @param level The damage level.
*/
public setBumperDamageLevel(bumperId: VehicleBumper, level: VehicleBumperDamage): void;
public setBumperDamageLevel(bumperId: T, level: V): void;
/**
* Sets the damage status of a vehicle based on a base64 string.
*
* @param data A base64 string that represents the damage status.
*/
public setDamageStatusBase64(data: string): void;
/**
* Sets the state of a specific door
*
* @param doorId The id of the door.
* @param state The state of the door.
*/
public setDoorState(doorId: VehicleDoor, state: VehicleDoorState): void;
public setDoorState(doorId: T, state: V): void;
/**
* Sets the state of an extra of a vehicle.
*
* @remarks Setting extras on vehicle does not work for every vehicle model. For example you can change the light bar of a police car with this method.
*
* @param extraId The id of the extra.
* @param state The state of the extra.
*/
public setExtra(extraId: number, state: boolean): void;
/**
* Sets the game state data of a vehicle with a given base64 string.
*
* @param data A base64 string that represents the game state data.
*/
public setGamestateDataBase64(data: string): void;
/**
* Sets the health data of a vehicle with a given base64 string.
*
* @param data A base64 string that represents the health data.
*/
public setHealthDataBase64(data: string): void;
/**
* Sets a specific light of the vehicle either damaged or not.
*
* @param lightId The id of the light.
* @param isDamaged True to damage the specific light, otherwise false.
*/
public setLightDamaged(lightId: number, isDamaged: boolean): void;
/**
* Applies a specific mod of a given mod type.
*
* @param modType The type of the mod.
* @param modId The id of the mod.
*/
public setMod(modType: VehicleModType, modId: number): void;
public setMod(modType: T, modId: number): void;
/**
* Applies bullet holes to a specific vehicle part.
*
* @param partId The id of the part.
* @param count The amount of bullet holes.
*/
public setPartBulletHoles(partId: VehiclePart, count: number): void;
public setPartBulletHoles(partId: T, count: number): void;
/**
* Sets the damage level of a vehicle part.
*
* @param partId The id of the part.
* @param level The damage level.
*/
public setPartDamageLevel(partId: VehiclePart, level: VehiclePartDamage): void;
public setPartDamageLevel(partId: T, level: V): void;
/**
* Sets type of the rear wheels.
*
* @param wheelId The id of the rear wheel type.
*/
public setRearWheels(wheelId: number): void;
/**
* Sets the script data of a vehicle based on a base64 string.
*
* @param data A base64 string that represents the script data.
*/
public setScriptDataBase64(data: string): void;
/**
* Sets if a special light is damaged.
*
* @param specialLightId The id of the special light.
* @param isDamaged True to damage the specific special light, otherwise false.
*/
public setSpecialLightDamaged(specialLightId: number, isDamaged: boolean): void;
/**
* Sets if a specific wheel is burst.
*
* @param wheelId The id of the wheel.
* @param state True to burst the wheel, otherwise false.
*/
public setWheelBurst(wheelId: number, state: boolean): void;
/**
* Sets a wheel either detached or attached.
*
* @param wheelId The id of the wheel.
* @param state True to detach the wheel, otherwise false.
*/
public setWheelDetached(wheelId: number, state: boolean): void;
/**
* Sets if a specific wheel has a tire.
*
* @param wheelId The id of the wheel.
* @param state True to apply a tire to a wheel, otherwise false.
*/
public setWheelHasTire(wheelId: number, state: boolean): void;
/**
* Sets the health of a specific wheel.
*
* @param wheelId The id of the wheel.
* @param health The health of the wheel.
*/
public setWheelHealth(wheelId: number, health: number): void;
/**
* Sets a wheel either on fire or not
*
* @param wheelId The id of the wheel.
* @param state True to set the wheel on fire, otherwise false.
*/
public setWheelOnFire(wheelId: number, state: boolean): void;
/**
* Applies a wheel style based on the type and variation.
*
* @param wheelType The type of the wheel.
* @param wheelId The variation id of the wheel.
*/
public setWheels(wheelType: number, wheelId: number): void;
/**
* Gets the camber angle of the specified wheel.
*
* @param wheelIndex The index of the wheel.
*/
public getWheelCamber(wheelIndex: number): number;
/**
* Sets the camber angle of the specified wheel.
*
* @remarks A positive camber angle means that the top of the wheel is farther out than the bottom. A negative camber angle means that the bottom of the wheel is farther out than the top.
*
* @param wheelIndex The index of the wheel.
* @param camber The value the of camber angle.
*/
public setWheelCamber(wheelIndex: number, camber: number): void;
/**
* Gets the track width of the specified wheel.
*
* @param wheelIndex The index of the wheel.
*/
public getWheelTrackWidth(wheelIndex: number): number;
/**
* Sets the track width of the specified wheel.
*
* @param wheelIndex The index of the wheel.
* @param width The value of the track width.
*/
public setWheelTrackWidth(wheelIndex: number, width: number): void;
/**
* Gets the height of the specified wheel.
*
* @param wheelIndex The index of the wheel.
*/
public getWheelHeight(wheelIndex: number): number;
/**
* Sets the height of the specified wheel.
*
* @param wheelIndex The index of the wheel.
* @param height The value of the wheel height.
*/
public setWheelHeight(wheelIndex: number, height: number): void;
/**
* Gets the tyre radius of the specified wheel.
*
* @param wheelIndex The index of the wheel.
*/
public getWheelTyreRadius(wheelIndex: number): number;
/**
* @remarks Applies only physical effects to the wheel.
*
* @param wheelIndex The index of the wheel.
* @param radius The value of the tyre radius.
*/
public setWheelTyreRadius(wheelIndex: number, radius: number): void;
/**
* Gets the rim radius of the specified wheel.
*
* @param wheelIndex The index of the wheel.
*/
public getWheelRimRadius(wheelIndex: number): number;
/**
* @remarks Does not show any visible effect.
*
* @param wheelIndex The index of the wheel.
* @param radius The index of the rim radius.
*/
public setWheelRimRadius(wheelIndex: number, radius: number): void;
/**
* Gets the tyre width the specified wheel.
*
* @param wheelIndex The index of the wheel.
*/
public getWheelTyreWidth(wheelIndex: number): number;
/**
* @remarks Does not show any visible effect.
*
* @param wheelIndex The index of the wheel.
* @param width The value of the tyre width.
*/
public setWheelTyreWidth(wheelIndex: number, width: number): void;
/**
* Sets if a specific window is damaged.
*
* @param windowId The id of the window.
* @param isDamaged True to damage the specific window, otherwise false.
*/
public setWindowDamaged(windowId: number, isDamaged: boolean): void;
/**
* Sets if a specific window is open.
*
* @param windowId The id of the window.
* @param state True to open the window, otherwise false.
*/
public setWindowOpened(windowId: number, state: boolean): void;
/**
* Repairs a specific wheel.
*
* @param wheelId The id of the wheel.
*/
public setWheelFixed(wheelId: number): void;
/**
* Gets or sets if the created train is a mission train.
*/
public isMissionTrain: boolean;
/**
* Gets or sets the track id of the train.
*
* @remarks Valid track ids are between 0 and 11.
*/
public trainTrackId: number;
/**
* Gets the engine of the train.
*/
public readonly trainEngineId: Vehicle | null;
/**
* Set a train as an engine of a train.
*
* @param vehicle The vehicle to set as an engine.
*/
public setTrainEngineId(vehicle: Vehicle | null): void;
/**
* Gets or sets the trains config index.
*
* @remarks You can find a list of all possible config indices in the trains.xml. Valid indices are between 1 and 25.
*/
public trainConfigIndex: number;
/**
* Gets or sets the distance of the trains to the engine.
*/
public trainDistanceFromEngine: number;
/**
* Gets or sets if the train is the engine of the train.
*/
public isTrainEngine: boolean;
/**
* Gets or sets if the train is a caboose.
*/
public isTrainCaboose: boolean;
/**
* Gets or sets if the train is a passenger carriage.
*/
public trainPassengerCarriages: boolean;
/**
* Gets or sets the direction of the train.
*/
public trainDirection: boolean;
/**
* Gets or sets if the trains is rendered derailed.
*/
public trainRenderDerailed: boolean;
/**
* Gets or sets if the doors of the trains should be forced open.
*/
public trainForceDoorsOpen: boolean;
/**
* Gets or sets the cruise speed of the train.
*/
public trainCruiseSpeed: number;
/**
* Gets or sets the config index of the train's carriage.
*/
public trainCarriageConfigIndex: number;
/**
* Gets another train that is linked to the back of the train. Returns null if there is no linked train.
*/
public readonly trainLinkedToBackwardId: Vehicle | null;
/**
* Links another train to the back of the train.
*
* @param vehicle The vehicle to set as linked to the back of the train.
*/
public setTrainLinkedToBackwardId(vehicle: Vehicle | null): void;
/**
* Gets another train that is linked to the back of the train. Returns null if there is no linked train in front.
*/
public readonly trainLinkedToForwardId: Vehicle | null;
/**
* Links another train to the front of the train.
*
* @param vehicle The vehicle to set as linked to the front of the train.
*/
public setTrainLinkedToForwardId(vehicle: Vehicle | null): void;
public trainUnk1: boolean;
public trainUnk2: boolean;
public trainUnk3: boolean;
/**
* Activates the searchlight and follows the target.
*
* @remarks Entity parameter isn't working for now and this can only be used for helicopter searchlights.
*/
public setSearchLightTo(entity: Entity, state: boolean): void;
/**
* Gets or sets the status of the boat anchor.
*/
public boatAnchorActive: boolean;
public lightState: number;
public hornActive: boolean;
public setTimedExplosion(state: boolean, culprit: Player, time: number): void;
public readonly timedExplosionTime: number;
public readonly timedExplosionCulprit: Player;
public readonly hasTimedExplosion: boolean;
public rocketRefuelSpeed: number;
public counterMeasureCount: number;
/**
* @remarks Value is in meters per second.
*/
public scriptMaxSpeed: number;
public getWeaponCapacity(weaponIndex: number): number;
public setWeaponCapacity(weaponIndex: number, capacity: number): void;
setBadge(textureDictionary: number, texture: number, pos: VehicleBadgePosition, pos2?: VehicleBadgePosition, pos3?: VehicleBadgePosition, pos4?: VehicleBadgePosition): void;
public hybridExtraActive: boolean;
public hybridExtraState: number;
public readonly steeringAngle: number;
public readonly accelerationLevel: number;
public readonly brakeLevel: number;
// normal meta
public setMeta(key: K, value: shared.InterfaceValueByKey): void;
public setMeta>(key: K, value: ICustomVehicleMeta[K]): void;
/** @deprecated See {@link ICustomVehicleMeta} */
public setMeta(key: K, value: shared.InterfaceValueByKey): void;
public setMeta(values: shared.MetaValues): void;
public deleteMeta(key: string): void;
public deleteMeta>(key: K): void;
public getMeta(key: Exclude): unknown;
public getMeta>(key: K): ICustomVehicleMeta[K] | undefined;
/** @deprecated See {@link ICustomVehicleMeta} */
public getMeta(key: string): V | undefined;
public hasMeta(key: string): boolean;
public hasMeta>(key: K): boolean;
// synced meta
public setSyncedMeta(key: K, value: shared.InterfaceValueByKey): void;
public setSyncedMeta>(key: K, value: shared.ICustomVehicleSyncedMeta[K]): void;
/** @deprecated See {@link "alt-shared".ICustomVehicleSyncedMeta} */
public setSyncedMeta(key: K, value: shared.InterfaceValueByKey): void;
public setSyncedMeta(values: shared.MetaValues): void;
public deleteSyncedMeta(key: string): void;
public deleteSyncedMeta>(key: K): void;
public getSyncedMeta(key: Exclude): unknown;
public getSyncedMeta>(key: K): shared.ICustomVehicleSyncedMeta[K] | undefined;
/** @deprecated See {@link "alt-shared".ICustomVehicleSyncedMeta} */
public getSyncedMeta(key: string): V | undefined;
public hasSyncedMeta(key: string): boolean;
public hasSyncedMeta>(key: K): boolean;
// stream synced meta
public setStreamSyncedMeta(key: K, value: shared.InterfaceValueByKey): void;
public setStreamSyncedMeta>(key: K, value: shared.ICustomVehicleStreamSyncedMeta[K]): void;
/** @deprecated See {@link "alt-shared".ICustomVehicleStreamSyncedMeta} */
public setStreamSyncedMeta(key: K, value: shared.InterfaceValueByKey): void;
public setStreamSyncedMeta(values: shared.MetaValues): void;
public deleteStreamSyncedMeta(key: string): void;
public deleteStreamSyncedMeta>(key: K): void;
public getStreamSyncedMeta(key: Exclude): unknown;
public getStreamSyncedMeta>(key: K): shared.ICustomVehicleStreamSyncedMeta[K] | undefined;
/** @deprecated See {@link "alt-shared".ICustomVehicleStreamSyncedMeta} */
public getStreamSyncedMeta(key: string): V | undefined;
public hasStreamSyncedMeta(key: string): boolean;
public hasStreamSyncedMeta>(key: K): boolean;
}
export class Blip extends WorldObject {
/**
* Array with all blips.
*
* @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 blips = alt.Blip.all; // Store it in a variable, so it doesn't create a copy of the array on each iteration
* for(let i = 0; i < blips.length; i++)
* {
* alt.log(`${blips[i].scriptID}`); // Logs the scriptID of every blip
* }
* ```
*/
public static readonly all: readonly Blip[];
public static readonly count: number;
/**
* Retrieves the blip from the pool.
*
* @param id The id of the blip.
* @returns Entity if it was found, otherwise null.
*
*/
public static getByID(id: number): Blip | null;
public routeColor: shared.RGBA;
public sprite: shared.BlipSprite;
/**
* @remarks Does't properly work for areablips currently.
*/
public size: shared.Vector2;
public scale: number;
public color: shared.BlipColor | number;
public secondaryColor: number | shared.RGBA;
public alpha: number;
public flashTimer: number;
public flashInterval: number;
public route: boolean;
public bright: boolean;
public number: number;
public display: number;
public showCone: boolean;
public flashes: boolean;
public flashesAlternate: boolean;
public shortRange: boolean;
public priority: number;
public heading: number;
public gxtName: string;
public name: string;
public pulse: boolean;
public asMissionCreator: boolean;
public tickVisible: boolean;
public headingIndicatorVisible: boolean;
public outlineIndicatorVisible: boolean;
public friendIndicatorVisible: boolean;
public crewIndicatorVisible: boolean;
public category: number;
public highDetail: boolean;
public shrinked: boolean;
public attachedTo: Entity | null;
public fade(opacity: number, duration: number): void;
public visible: boolean;
public blipType: shared.BlipType;
public isFriendly: boolean;
public readonly isAttached: boolean;
public isGlobal: boolean;
public readonly targets: readonly Player[];
public addTarget(player: Player): void;
public removeTarget(player: Player): void;
public deleteMeta(key: string): void;
public deleteMeta>(key: K): void;
public hasMeta(key: string): boolean;
public hasMeta>(key: K): boolean;
public getMeta(key: Exclude): unknown;
public getMeta>(key: K): ICustomBlipMeta[K] | undefined;
/** @deprecated See {@link ICustomBlipMeta} */
public getMeta(key: string): V | undefined;
public setMeta(key: K, value: shared.InterfaceValueByKey): void;
public setMeta>(key: K, value: ICustomBlipMeta[K]): void;
/** @deprecated See {@link ICustomBlipMeta} */
public setMeta(key: K, value: shared.InterfaceValueByKey): void;
public setMeta(values: shared.MetaValues): void;
}
export class AreaBlip extends Blip {
constructor(x: number, y: number, z: number, width: number, height: number, global: boolean);
}
export class RadiusBlip extends Blip {
constructor(x: number, y: number, z: number, radius: number, global: boolean);
}
export class PointBlip extends Blip {
constructor(x: number, y: number, z: number, global: boolean);
constructor(pos: shared.Vector3, global: boolean);
constructor(entity: Entity, global: boolean);
}
export class Colshape extends WorldObject {
public static readonly all: readonly Colshape[];
public readonly colshapeType: shared.ColShapeType;
/**
* Whether this colshape should only trigger its enter/leave events for players or all entities.
*/
public playersOnly: boolean;
public readonly radius: number;
public readonly height: number;
public readonly min: shared.Vector2 | shared.Vector3;
public readonly max: shared.Vector2 | shared.Vector3;
public readonly minZ: number;
public readonly maxZ: number;
public readonly points: readonly shared.Vector2[];
/**
* Retrieves the colshape from the pool.
*
* @param id The id of the colshape.
* @returns Entity if it was found, otherwise null.
*
*/
public static getByID(id: number): Colshape | null;
public isEntityIn(entity: Entity): boolean;
public isEntityIn(entityID: number): boolean;
public isPointIn(position: shared.IVector3): boolean;
public deleteMeta(key: string): void;
public deleteMeta>(key: K): void;
public hasMeta(key: string): boolean;
public hasMeta>(key: K): boolean;
public getMeta(key: Exclude): unknown;
public getMeta>(key: K): ICustomColshapeMeta[K] | undefined;
/** @deprecated See {@link ICustomColshapeMeta} */
public getMeta(key: string): V | undefined;
public setMeta(key: K, value: shared.InterfaceValueByKey): void;
public setMeta>(key: K, value: ICustomColshapeMeta[K]): void;
/** @deprecated See {@link ICustomColshapeMeta} */
public setMeta(key: K, value: shared.InterfaceValueByKey): void;
public setMeta(values: shared.MetaValues): void;
}
export class ColshapeCylinder extends Colshape {
constructor(x: number, y: number, z: number, radius: number, height: number);
}
export class ColshapeSphere extends Colshape {
constructor(x: number, y: number, z: number, radius: number);
}
export class ColshapeCircle extends Colshape {
constructor(x: number, y: number, radius: number);
}
export class ColshapeCuboid extends Colshape {
constructor(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number);
}
export class ColshapeRectangle extends Colshape {
constructor(x1: number, y1: number, x2: number, y2: number);
}
export class ColshapePolygon extends Colshape {
constructor(minZ: number, maxZ: number, points: shared.IVector2[]);
}
export class Checkpoint extends Colshape {
constructor(type: shared.CheckpointType, x: number, y: number, z: number, radius: number, height: number, r: number, g: number, b: number, a: number, streamingDistance: number);
constructor(type: shared.CheckpointType, pos: shared.IVector3, radius: number, height: number, color: 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 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 deleteMeta(key: string): void;
public deleteMeta>(key: K): void;
public hasMeta(key: string): boolean;
public hasMeta>(key: K): boolean;
public getMeta(key: Exclude): unknown;
public getMeta>(key: K): ICustomCheckpointMeta[K] | undefined;
public setMeta(key: K, value: shared.InterfaceValueByKey): void;
public setMeta>(key: K, value: ICustomCheckpointMeta[K]): void;
public setMeta(values: shared.MetaValues): void;
public setStreamSyncedMeta(key: K, value: shared.InterfaceValueByKey): void;
public setStreamSyncedMeta>(key: K, value: shared.ICustomCheckpointStreamSyncedMeta[K]): void;
public setStreamSyncedMeta(values: shared.MetaValues): void;
public deleteStreamSyncedMeta(key: string): void;
public deleteStreamSyncedMeta>(key: K): void;
public getStreamSyncedMeta(key: Exclude): unknown;
public getStreamSyncedMeta>(key: K): shared.ICustomCheckpointStreamSyncedMeta[K] | undefined;
public hasStreamSyncedMeta(key: string): boolean;
public hasStreamSyncedMeta>(key: K): boolean;
public getStreamSyncedMetaKeys(): readonly string[];
}
export class VoiceChannel extends BaseObject {
/**
* Creates a new voice channel.
*
* @remarks This throws an error when the voice chat is not activated on serverside.
*
* @param isSpatial Whether the voice channel should be 3D (e.g. talking in person) or 1D (e.g. talking over a telephone).
* @param maxDistance The max distance at which you can hear each other.
*/
constructor(isSpatial: boolean, maxDistance: number);
public readonly maxDistance: number;
public readonly isSpatial: boolean;
/**
* Priority of voice channel.
* If a player is in two channels and both can be heard by another player, only one should play the voice.
* Value is of type integer, can be negative.
*/
public priority: number;
/**
* Hash of the filter name (should also be created on clientside).
* See docs: [Audio filters](https://docs.altv.mp/articles/audio_filters.html), [Voice](https://docs.altv.mp/articles/voice.html).
*/
public filter: number;
public addPlayer(player: Player): void;
public isPlayerInChannel(player: Player): boolean;
public isPlayerMuted(player: Player): boolean;
public mutePlayer(player: Player): void;
public removePlayer(player: Player): void;
public unmutePlayer(player: Player): void;
public deleteMeta(key: string): void;
public deleteMeta>(key: K): void;
public hasMeta(key: string): boolean;
public hasMeta>(key: K): boolean;
public getMeta(key: Exclude): unknown;
public getMeta>(key: K): ICustomVoiceChannelMeta[K] | undefined;
/** @deprecated See {@link ICustomVoiceChannelMeta} */
public getMeta(key: string): V | undefined;
public setMeta(key: K, value: shared.InterfaceValueByKey): void;
public setMeta>(key: K, value: ICustomVoiceChannelMeta[K]): void;
/** @deprecated See {@link ICustomVoiceChannelMeta} */
public setMeta(key: K, value: shared.InterfaceValueByKey): void;
public setMeta(values: shared.MetaValues): void;
public readonly players: readonly Player[];
public readonly playerCount: number;
}
export class Resource extends shared.Resource {
public readonly path: string;
public static getByName(name: string): Resource | null;
public static readonly all: readonly Resource[];
public static readonly current: Resource;
}
// Do not add anything here, add to the Utils namespace instead!
// (this class is here only for extending shared Utils class & namespace)
export class Utils extends shared.Utils {
protected constructor();
}
export namespace Utils {
/**
* Finds the closest player (if any) from {@link Player.all alt.Player.all}.
*
* `pos` - From which position to look for the nearest player.
*
* `range` - In which range to search for the nearest vehicle. Defaults to `Infinity`.
*/
export function getClosestPlayer(options: { pos: shared.IVector3; range?: number }): Player | null;
/**
* Finds the closest vehicle (if any) from {@link Vehicle.all alt.Vehicle.all}.
*
* `pos` - From which position to look for the nearest vehicle.
*
* `range` - In which range to search for the nearest vehicle. Defaults to `Infinity`.
*/
export function getClosestVehicle(options: { pos: shared.IVector3; range?: number }): Vehicle | null;
}
/**
* Stores the given value with the specified key.
*
* @remarks The given value will be shared with all client resources.
*
* @param key The key of the value to store.
* @param value The value to store.
*/
export function setSyncedMeta(key: K, value: shared.InterfaceValueByKey): void;
export function setSyncedMeta>(key: K, value: shared.ICustomGlobalSyncedMeta[K]): void;
/** @deprecated See {@link "alt-shared".ICustomGlobalSyncedMeta} */
export function setSyncedMeta(key: K, value: shared.InterfaceValueByKey): void;
/**
* Removes the specified key and the data connected to that specific key.
*
* @param key The key of the value to remove.
*/
export function deleteSyncedMeta(key: string): void;
export function deleteSyncedMeta>(key: K): void;
/**
* Emits specified event across resources.
*
* @param eventName Name of the event.
* @param args Rest parameters for emit to send.
*/
// Do not allow to emit alt:V event name
export function emit(eventName: K, ...args: Parameters): void;
export function emit(eventName: Exclude, ...args: any[]): void;
/**
* Emits specified event across resources.
*
* @param eventName Name of the event.
* @param args Rest parameters for emit to send.
*
* @remarks Works only from JS resource to JS resource
*/
// Do not allow to emit alt:V event name
export function emitRaw(eventName: K, ...args: Parameters): void;
export function emitRaw(eventName: Exclude, ...args: any[]): void;
/**
* Emits specified event to specific client.
*
* @param player Event is sent to specific player or players.
* @param eventName Name of the event.
* @param args Rest parameters for emit to send.
*/
export function emitClient(player: Player | Player[], eventName: K, ...args: Parameters): void;
export function emitClient(player: Player | Player[], eventName: Exclude, ...args: any[]): void;
/**
* Emits specified event to specific client.
*
* @param player Event is sent to specific player or players.
* @param eventName Name of the event.
* @param args Rest parameters for emit to send.
*/
export function emitClientRaw(player: Player | Player[], eventName: K, ...args: Parameters): void;
export function emitClientRaw(player: Player | Player[], eventName: Exclude, ...args: any[]): void;
/**
* Emits specified event to specific client.
*
* @param player Event is sent to specific player or players.
* @param eventName Name of the event.
* @param args Rest parameters for emit to send.
*
* @remarks Unreliable event should be used when you don't need to be sure that event will be received by client.
*
*/
export function emitClientUnreliable