@altv/types-server
Version:
This package contains types definitions for alt:V server-side module.
1,390 lines (1,243 loc) • 130 kB
TypeScript
/// <reference types="@altv/types-shared"/>
/**
* @module alt-server
*/
declare module "alt-server" {
import * as shared from "alt-shared";
export type DateTimeHour = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23;
export type DateTimeMinute = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59;
export type DateTimeSecond = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59;
export type DateTimeDay = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30;
export type DateTimeMonth = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;
export enum ExplosionType {
Grenade,
GrenadeLauncher,
StickyBomb,
Molotov,
Rocket,
TankShell,
HiOctane,
Car,
Plane,
PetrolPump,
Bike,
DirSteam,
DirFlame,
DirWaterHydrant,
DirGasCanister,
Boat,
ShipDestroy,
Truck,
Bullet,
SmokeGrenadeLauncher,
SmokeGrenade,
BzGas,
Flare,
GasCanister,
Extinguisher,
ProgrammableAr,
Train,
Barrel,
Propane,
Blimp,
DirFlameExplode,
Tanker,
PlaneRocket,
VehicleBullet,
GasTank,
Firework,
Snowball,
ProxMine,
ValkyrieCannon,
Unknown = -1,
}
export enum RadioStation {
LosSantosRockRadio,
NonStopPopFm,
RadioLosSantos,
ChannelX,
WestCoastTalkRadio,
RebelRadio,
SoulwaxFm,
EastLosFm,
WestCoastClassics,
BlaineCountyRadio,
TheBlueArk,
WorldWideFm,
FlyloFm,
TheLowdown,
RadioMirrorPark,
Space,
VinewoodBoulevardRadio,
SelfRadio,
TheLab,
RadioOff = 255,
}
export enum NumberPlateStyle {
BlueWhite,
YellowBlack,
YellowBlue,
BlueWhite2,
BlueWhite3,
Yankton,
}
export enum VehicleBumper {
Front,
Rear,
}
export enum VehicleBumperDamage {
NotDamaged,
Damaged,
None,
}
export enum VehicleDoor {
DriverFront,
PassengerFront,
DriverRear,
PassengerRear,
Hood,
Trunk,
}
export enum VehicleDoorState {
Closed,
OpenedLevel1,
OpenedLevel2,
OpenedLevel3,
OpenedLevel4,
OpenedLevel5,
OpenedLevel6,
OpenedLevel7,
Unknown = 255,
}
export enum VehicleModType {
Spoiler,
FrontBumper,
RearBumper,
SideSkirt,
Exhaust,
Frame,
Grille,
Hood,
Fender,
RightFender,
Roof,
Engine,
Brakes,
Transmission,
Horn,
Suspension,
Armor,
Unk1,
Turbo,
Unk2,
TireSmoke,
Unk3,
XenonLights,
FrontWheels,
BackWheels,
Plateholder,
VanityPlates,
TrimDesign,
Ornaments,
Dashboard,
Dial,
DoorSpeaker,
Seats,
SteeringWheel,
ColumnShifterLeavers,
Plaques,
Speakers,
Trunk,
Hydraulics,
EngineBlock,
AirFilter,
Struts,
ArchCover,
Aerials,
Trim,
Tank,
Windows,
Unk4,
Livery,
}
export enum VehiclePart {
FrontLeft,
FrontRight,
MiddleLeft,
MiddleRight,
RearLeft,
RearRight,
}
export enum VehiclePartDamage {
NotDamaged,
DamagedLevel1,
DamagedLevel2,
DamagedLevel3,
}
export enum WeatherType {
ExtraSunny,
Clear,
Clouds,
Smog,
Foggy,
Overcast,
Rain,
Thunder,
Clearing,
Neutral,
Snow,
Blizzard,
Snowlight,
Xmas,
Halloween,
}
export enum WindowTint {
None,
PureBlack,
DarkSmoke,
LightSmoke,
Stock,
Limo,
Green,
}
export enum BaseObjectFilterType {
Player = 1,
Vehicle = 2,
Ped = 4,
Object = 8,
}
export enum Benefit {
None,
CloudAuth,
}
export enum CloudAuthResult {
Success,
NoBenefit,
VerifyFailed,
}
export interface VehicleBadgePosition {
active: boolean;
alpha: number;
size: number;
boneIndex: number;
offset: shared.Vector3;
direction: shared.Vector3;
side: shared.Vector3;
}
export interface IConnectionInfo {
readonly name: string;
readonly socialID: string;
readonly hwidHash: string;
readonly hwidExHash: string;
readonly authToken: string;
readonly isDebug: boolean;
readonly branch: string;
readonly build: number;
readonly cdnUrl: string;
readonly passwordHash: string;
readonly ip: string;
readonly discordUserID: string;
readonly socialClubName: string;
readonly cloudID: string;
readonly cloudAuthResult: CloudAuthResult;
readonly id: number;
readonly isAccepted: boolean;
readonly hwid3: string;
/**
* Set text for (potential) player in queue.
*
* @example
* ```js
* alt.on("connectionQueueAdd", (connection) => {
* connection.text = "Your position in queue: 3";
* })
* ```
*/
text: string;
/**
* Accepts client connection.
*
* @param sendNames Send names of all players on server to this client. Defaults to `true`.
*/
accept: (sendNames?: boolean) => void;
decline: (reason: string) => void;
}
export class ConnectionInfo {
static readonly all: readonly IConnectionInfo[];
static getByID(id: number): IConnectionInfo | null;
}
export enum ConnectDeniedReason {
WRONG_VERSION,
WRONG_BRANCH,
DEBUG_NOT_ALLOWED,
WRONG_PASSWORD,
WRONG_CDN_URL,
}
export interface IServerEvent {
anyResourceError: (resourceName: string) => void;
anyResourceStart: (resourceName: string) => void;
anyResourceStop: (resourceName: string) => void;
consoleCommand: (name: string, ...args: string[]) => void;
entityEnterColshape: (colshape: Colshape, entity: Entity) => void;
entityLeaveColshape: (colshape: Colshape, entity: Entity) => void;
explosion: (source: Player, type: ExplosionType, pos: shared.Vector3, fx: number, target: Entity | null) => boolean | void;
netOwnerChange: (entity: Entity, owner: Player | null, oldOwner: Player | null) => void;
/**
* @remarks The seat indexes start with 1 (driver seat).
*/
playerChangedVehicleSeat: (player: Player, vehicle: Vehicle, oldSeat: number, seat: number) => void;
playerConnect: (player: Player) => void;
playerConnectDenied: (reason: ConnectDeniedReason, name: string, ip: string, passwordHash: number, isDebug: boolean, branch: string, version: number, cdnURL: string, discordId: number) => void;
playerDamage: (victim: Player, attacker: Entity | null, healthDamage: number, armourDamage: number, weaponHash: number) => void;
playerDeath: (victim: Player, killer: Entity | null, weaponHash: number) => void;
playerDisconnect: (player: Player, reason: string) => void;
/**
* @remarks The seat indexes start with 1 (driver seat).
*/
playerEnteredVehicle: (player: Player, vehicle: Vehicle, seat: number) => void;
/**
* @remarks The seat indexes start with 1 (driver seat).
*/
playerEnteringVehicle: (player: Player, vehicle: Vehicle, seat: number) => void;
/**
* @remarks The seat indexes start with 1 (driver seat).
*/
playerLeftVehicle: (player: Player, vehicle: Vehicle, seat: number) => 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;
vehicleAttach: (vehicle: Vehicle, attachedVehicle: Vehicle) => void;
vehicleDestroy: (vehicle: Vehicle) => void;
vehicleDetach: (vehicle: Vehicle, detachedVehicle: Vehicle) => void;
weaponDamage: (source: Player, target: Entity, weaponHash: number, damage: number, offset: shared.Vector3, bodyPart: shared.BodyPart, sourceEntity: Entity) => number | boolean | void;
startFire: (player: Player, fires: IFireInfo[]) => boolean | void;
startProjectile: (player: Player, pos: shared.Vector3, dir: shared.Vector3, ammoHash: number, weaponHash: number) => boolean | void;
playerWeaponChange: (player: Player, oldWeapon: number, weapon: number) => void;
vehicleDamage: (vehicle: Vehicle, attacker: Entity | null, bodyHealthDamage: number, additionalBodyHealthDamage: number, engineHealthDamage: number, petrolTankDamage: number, weapon: number) => void;
localMetaChange: (player: Player, key: string, newValue: any, oldValue: any) => void;
connectionQueueAdd: (connectionInfo: IConnectionInfo) => void;
connectionQueueRemove: (connectionInfo: IConnectionInfo) => void;
serverStarted: () => void;
playerRequestControl: (player: Player, target: Entity) => boolean | void;
playerAnimationChange: (target: Player, oldAnimDict: number, newAnimDict: number, oldAnimName: number, newAnimName: number) => void;
playerInteriorChange: (player: Player, oldInterior: number, newInterior: number) => void;
playerDimensionChange: (player: Player, oldDimension: number, newDimension: number) => void;
vehicleHorn: (vehicle: Vehicle, player: Player, state: boolean) => boolean | void;
vehicleSiren: (vehicle: Vehicle, state: boolean) => void;
playerSpawn: (player: Player) => void;
baseObjectCreate: (baseObject: BaseObject) => void;
baseObjectRemove: (baseObject: BaseObject) => void;
metaChange: (target: BaseObject, key: string, value: any, oldValue: any) => void;
voiceConnection: (state: shared.VoiceConnectionState) => void;
/**
* @remarks You need to return true, otherwise the scene will not be synced.
*/
requestSyncedScene: (source: Player, sceneID: number) => void | boolean;
/**
* @remarks You need to return true, otherwise the scene will not be synced.
*/
startSyncedScene: (source: Player, sceneID: number, startPos: shared.Vector3, startRot: shared.Vector3, animDictHash: number, entityAnimPairs: { entity: BaseObject; animHash: number }[]) => void | boolean;
/**
* @remarks You need to return true, otherwise the scene will not be synced.
*/
stopSyncedScene: (source: Player, sceneID: number) => void | boolean;
/**
* @remarks You need to return true, otherwise the scene will not be synced.
*/
updateSyncedScene: (source: Player, startRate: number, sceneID: number) => void | boolean;
/**
* @remarks Triggers if player deletes a object of task.
*/
clientDeleteObject: (player: Player) => void | boolean;
/**
* @remarks Triggers if player request creation of a object, e.g for a task which is synced.
*/
clientRequestObject: (player: Player, model: number, position: shared.Vector3) => void | boolean;
playerHeal: (player: Player, oldHealth: number, newHealth: number, oldArmour: number, newArmour: number) => void;
givePedScriptedTask: (source: Player, target: Ped, task: number) => void | boolean;
pedDamage: (ped: Ped, attacker: Entity | null, healthDamage: number, armourDamage: number, weapon: number) => void | boolean;
pedDeath: (ped: Ped, killer: Entity | null, weaponHash: number) => void | boolean;
pedHeal: (ped: Ped, oldHealth: number, newHealth: number, oldArmour: number, newArmour: number) => void | boolean;
}
interface IVehiclePassenger {
[seat: string]: Player;
}
export interface IFireInfo {
readonly pos: shared.Vector3;
readonly weapon: number;
}
export interface IVehicleNeon {
left: boolean;
right: boolean;
front: boolean;
back: boolean;
}
export interface ICloth {
readonly drawable: number;
readonly texture: number;
readonly palette: number;
}
export interface IDlcCloth {
readonly drawable: number;
readonly texture: number;
readonly palette: number;
readonly dlc: number;
}
export interface IProp {
readonly drawable: number;
readonly texture: number;
}
export interface IDlcProp {
readonly drawable: number;
readonly texture: number;
readonly dlc: number;
}
export interface IHeadOverlay {
readonly index: number;
readonly opacity: number;
readonly colorType: number;
readonly colorIndex: number;
readonly secondColorIndex: number;
}
export interface IHeadBlendData {
readonly shapeFirstID: number;
readonly shapeSecondID: number;
readonly shapeThirdID: number;
readonly skinFirstID: number;
readonly skinSecondID: number;
readonly skinThirdID: number;
readonly shapeMix: number;
readonly skinMix: number;
readonly thirdMix: number;
}
export interface IBoneInfo {
readonly id: number;
readonly index: number;
readonly name: string;
}
export interface IVehicleModel {
readonly modelHash: number;
readonly title: string;
readonly type: shared.ModelType;
readonly wheelsCount: number;
readonly hasArmoredWindows: boolean;
readonly primaryColor: number;
readonly secondaryColor: number;
readonly pearlColor: number;
readonly wheelsColor: number;
readonly interiorColor: number;
readonly dashboardColor: number;
readonly hasAutoAttachTrailer: boolean;
readonly availableModkits: readonly boolean[];
hasExtra(extraId: number): boolean;
hasDefaultExtra(extraId: number): boolean;
readonly bones: readonly IBoneInfo[];
readonly canAttachCars: boolean;
readonly handlingNameHash: number;
}
export interface IPedModel {
readonly hash: number;
readonly name: string;
readonly type: string;
readonly dlcName: string;
readonly defaultUnarmedWeapon: string;
readonly movementClipSet: string;
readonly bones: readonly IBoneInfo[];
}
export interface IWeaponModel {
readonly hash: number;
readonly name: string;
readonly modelName: string;
readonly modelHash: number;
readonly ammoTypeHash: number;
readonly ammoType: string;
readonly ammoModelName: string;
readonly ammoModelHash: number;
readonly defaultMaxAmmoMp: number;
readonly skillAbove50MaxAmmoMp: number;
readonly maxSkillMaxAmmoMp: number;
readonly bonusMaxAmmoMp: number;
readonly damageType: string;
}
export interface IAmmoFlags {
readonly infiniteAmmo: boolean;
readonly addSmokeOnExplosion: boolean;
readonly fuse: boolean;
readonly fixedAfterExplosion: boolean;
}
export enum AmmoSpecialType {
None,
ArmorPiercing,
Explosive,
FullMetalJacket,
HollowPoint,
Incendiary,
Tracer,
}
export interface IDecoration {
readonly collection: number;
readonly overlay: number;
readonly count: number;
}
/**
* Extend it by interface merging for use in baseobject meta {@link "alt-server".BaseObject getMeta method}, {@link "alt-server".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-server".Blip getMeta method}, {@link "alt-server".Blip setMeta method}, etc.
*
* @remarks See {@link "alt-shared".ICustomGlobalMeta} for an example of use.
*/
export interface ICustomBlipMeta 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 interface merging for use in checkpoint meta {@link "alt-server".Checkpoint getMeta method}, {@link "alt-server".Checkpoint setMeta method}, etc.
*
* @remarks See {@link "alt-shared".ICustomGlobalMeta} for an example of use.
*/
export interface ICustomCheckpointMeta extends ICustomColshapeMeta {}
/**
* Extend it by interface merging for use in voice channel meta {@link "alt-server".VoiceChannel getMeta method}, {@link "alt-server".VoiceChannel setMeta method}, etc.
*
* @remarks See {@link "alt-shared".ICustomGlobalMeta} for an example of use.
*/
export interface ICustomVoiceChannelMeta extends ICustomBaseObjectMeta {}
/**
* Extend it by interface merging for use in entity meta {@link "alt-server".Entity getMeta method}, {@link "alt-server".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-server".Player getMeta method}, {@link "alt-server".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 vehicle meta {@link "alt-server".Vehicle getMeta method}, {@link "alt-server".Vehicle setMeta method}, etc.
*
* @remarks See {@link "alt-shared".ICustomGlobalMeta} for an example of use.
*/
export interface ICustomVehicleMeta extends ICustomEntityMeta {}
/**
* Extend `alt.emit` auto-completion by merging interfaces for use with `alt.emit`.
*
* @example
* ```ts
* declare module 'alt-server' {
* interface ICustomEmitEvent {
* myEvent: (arg1: string, arg2: { key: string, value: number })
* }
* }
* ```
*
* @export
* @interface ICustomEmitEvent
*/
export interface ICustomEmitEvent {}
/**
* Documentation: https://docs.altv.mp/articles/configs/server.html
*/
export interface IServerConfig {
readonly resources: readonly string[];
readonly modules: readonly string[];
readonly name?: string;
readonly host?: string;
readonly port?: number;
readonly players?: number;
readonly password?: string;
readonly announce?: boolean;
readonly token?: string;
readonly gamemode?: string;
readonly website?: string;
readonly language?: string;
readonly description?: string;
readonly debug?: boolean;
readonly streamingDistance?: number;
readonly migrationDistance?: number;
readonly timeout?: number;
readonly announceRetryErrorDelay?: number;
readonly announceRetryErrorAttempts?: number;
readonly duplicatePlayers?: number;
readonly tags?: readonly string[];
readonly useEarlyAuth?: boolean;
readonly earlyAuthUrl?: string;
readonly useCdn?: boolean;
readonly cdnUrl?: string;
readonly sendNames?: boolean;
readonly mapBoundsMinX?: number;
readonly mapBoundsMinY?: number;
readonly mapBoundsMaxX?: number;
readonly mapBoundsMaxY?: number;
readonly mapCellAreaSize?: number;
readonly colShapeTickRate?: number;
readonly logStream?: readonly string[];
readonly entityWorkerCount?: number;
readonly connectionQueue?: boolean;
readonly voice?: {
readonly bitrate?: number;
readonly externalSecret?: string;
readonly externalHost?: string;
readonly externalPort?: number;
readonly externalPublicHost?: string;
readonly externalPublicPort?: number;
};
readonly worldProfiler?: {
readonly port?: number;
readonly host?: string;
};
readonly "js-module"?: {
readonly "source-maps"?: boolean;
readonly "heap-profiler"?: boolean;
readonly profiler?: boolean;
readonly "global-fetch"?: boolean;
readonly "global-webcrypto"?: boolean;
readonly "network-imports"?: boolean;
readonly "extra-cli-args"?: readonly string[];
};
readonly "csharp-module"?: {
readonly disableDependencyDownload?: true;
};
readonly [key: string]: unknown;
}
/**
* The root directory of the server.
*/
export const rootDir: string;
export class BaseObject extends shared.BaseObject {
/**
* Gets the base object with the given type and id
*/
public static getByID(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;
/**
* Removes the specified key and the data connected to that specific key.
*
* @param key The key of the value to remove.
*/
public deleteSyncedMeta(key: string): void;
public deleteSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomBaseObjectSyncedMeta>>(key: K): void;
/**
* Stores the given value with the specified key.
*
* @remarks The given value will be shared with all clients.
*
* @param key The key of the value to store.
* @param value The value to store.
*/
public setSyncedMeta<K extends string>(key: K, value: shared.InterfaceValueByKey<shared.ICustomBaseObjectSyncedMeta, K>): void;
public setSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomBaseObjectSyncedMeta>>(key: K, value: shared.ICustomBaseObjectSyncedMeta[K]): void;
/** @deprecated See {@link "alt-shared".ICustomBaseObjectSyncedMeta} */
public setSyncedMeta<V extends any, K extends string = string>(key: K, value: shared.InterfaceValueByKey<shared.ICustomBaseObjectSyncedMeta, K, V>): void;
public setSyncedMeta(values: shared.MetaValues<shared.ICustomBaseObjectSyncedMeta>): void;
}
export class WorldObject extends BaseObject {
/**
* Object dimension.
*
* @remarks Check https://docs.altv.mp/articles/dimensions.html to understand how it works.
*/
public dimension: number;
/**
* Object position.
*/
public pos: shared.Vector3;
}
/** [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[];
/** Virtual Entity Group this entity belongs to */
public readonly group: VirtualEntityGroup;
/** Streaming range for the virtual entity */
public readonly streamingDistance: number;
public visible: 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 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.
*
* @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;
public getStreamSyncedMetaKeys(): readonly string[];
/**
* Stores the given value with the specified key.
*
* @remarks The given value will be shared with all clients in streaming range.
*
* @param key The key of the value to store.
* @param value The value to store.
*/
public setStreamSyncedMeta<K extends string>(key: K, value: shared.InterfaceValueByKey<shared.ICustomVirtualEntityStreamSyncedMeta, K>): void;
public setStreamSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomVirtualEntityStreamSyncedMeta>>(key: K, value: shared.ICustomVirtualEntityStreamSyncedMeta[K]): void;
/** @deprecated See {@link "alt-shared".ICustomVirtualEntityStreamSyncedMeta} */
public setStreamSyncedMeta<V extends any, K extends string = string>(key: K, value: shared.InterfaceValueByKey<shared.ICustomVirtualEntityStreamSyncedMeta, K, V>): void;
public setStreamSyncedMeta(values: shared.MetaValues<shared.ICustomVirtualEntityStreamSyncedMeta>): void;
/**
* Removes the specified key and the data connected to that specific key.
*
* @param key The key of the value to remove.
*/
public deleteStreamSyncedMeta(key: string): void;
public deleteStreamSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomVirtualEntityStreamSyncedMeta>>(key: K): 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[];
/**
* 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;
/**
* Entity model hash.
*/
public get model(): number;
public set model(model: number | string);
/**
* Entity rotation.
*
* @remarks Values are provided in radians.
*/
public rot: shared.Vector3;
/**
* Whether the entity is visible.
*/
public visible: boolean;
/**
* Whether the entity should be streamed for other entities.
*/
public streamed: boolean;
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;
/**
* Removes the specified key and the data connected to that specific key.
*
* @param key The key of the value to remove.
*/
public deleteSyncedMeta(key: string): void;
public deleteSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomEntitySyncedMeta>>(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 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[];
/**
* Stores the given value with the specified key.
*
* @remarks The given value will be shared with all clients.
*
* @param key The key of the value to store.
* @param value The value to store.
*/
public setSyncedMeta<K extends string>(key: K, value: shared.InterfaceValueByKey<shared.ICustomEntitySyncedMeta, K>): void;
public setSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomEntitySyncedMeta>>(key: K, value: shared.ICustomEntitySyncedMeta[K]): void;
/** @deprecated See {@link "alt-shared".ICustomEntitySyncedMeta} */
public setSyncedMeta<V extends any, K extends string = string>(key: K, value: shared.InterfaceValueByKey<shared.ICustomEntitySyncedMeta, K, V>): void;
public setSyncedMeta(values: shared.MetaValues<shared.ICustomEntitySyncedMeta>): void;
/**
* Removes the specified key and the data connected to that specific key.
*
* @param key The key of the value to remove.
*/
public deleteStreamSyncedMeta(key: string): void;
public deleteStreamSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomEntityStreamSyncedMeta>>(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 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[];
/**
* Stores the given value with the specified key.
*
* @remarks The given value will be shared with all clients in streaming range.
*
* @param key The key of the value to store.
* @param value The value to store.
*/
public setStreamSyncedMeta<K extends string>(key: K, value: shared.InterfaceValueByKey<shared.ICustomEntityStreamSyncedMeta, K>): void;
public setStreamSyncedMeta<K extends shared.ExtractStringKeys<shared.ICustomEntityStreamSyncedMeta>>(key: K, value: shared.ICustomEntityStreamSyncedMeta[K]): void;
/** @deprecated See {@link "alt-shared".ICustomEntityStreamSyncedMeta} */
public setStreamSyncedMeta<V extends any, K extends string = string>(key: K, value: shared.InterfaceValueByKey<shared.ICustomEntityStreamSyncedMeta, K, V>): void;
public setStreamSyncedMeta(values: shared.MetaValues<shared.ICustomEntityStreamSyncedMeta>): void;
/**
* Changes network owner to the specified player.
*
* @remarks See {@link Entity~netOwner} to understand how network owner works.
* <p><b>
* Keep in mind that disabling migration can lead to unexpected behaviour when
* the network owner gets out of the streaming range.
* </b></p>
*
* @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.
* <p><b>
* Keep in mind that disabling migration can lead to unexpected behaviour when
* the network owner gets out of the streaming range.
* </b></p>
*
* @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<K extends keyof shared.ICustomServerClientEvent>(eventName: K, ...args: Parameters<shared.ICustomServerClientEvent[K]>): void;
public emit<K extends string>(eventName: Exclude<K, keyof shared.ICustomServerClientEvent>, ...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<K extends keyof shared.ICustomServerClientEvent>(eventName: K, ...args: Parameters<shared.ICustomServerClientEvent[K]>): void;
public emitRaw<K extends string>(eventName: Exclude<K, keyof shared.ICustomServerClientEvent>, ...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<K extends keyof shared.ICustomServerClientRpc>(rpcName: K, ...args: Parameters<shared.ICustomServerClientRpc[K]>): Promise<ReturnType<shared.ICustomServerClientRpc[K]>>;
public emitRpc<K extends string>(rpcName: Exclude<K, keyof shared.ICustomServerClientRpc>, ...args: any[]): Promise<any>;
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<T extends number>(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