Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "alt-client"

module

alt-client

Index

References

Enumerations

Classes

Interfaces

Functions

References

AudioCategories

Re-exports AudioCategories

BaseObject

Re-exports BaseObject

BaseObjectType

Re-exports BaseObjectType

BlipColor

Re-exports BlipColor

BlipSprite

Re-exports BlipSprite

BlipType

Re-exports BlipType

BodyPart

Re-exports BodyPart

CheckpointType

Re-exports CheckpointType

ColShapeType

Re-exports ColShapeType

File

Re-exports File

FileEncoding

Re-exports FileEncoding

ICustomBaseObjectMeta

Re-exports ICustomBaseObjectMeta

ICustomBaseObjectSyncedMeta

Re-exports ICustomBaseObjectSyncedMeta

ICustomClientServerEvent

Re-exports ICustomClientServerEvent

ICustomClientServerRpc

Re-exports ICustomClientServerRpc

ICustomEntityStreamSyncedMeta

Re-exports ICustomEntityStreamSyncedMeta

ICustomEntitySyncedMeta

Re-exports ICustomEntitySyncedMeta

ICustomGlobalMeta

Re-exports ICustomGlobalMeta

ICustomGlobalSyncedMeta

Re-exports ICustomGlobalSyncedMeta

ICustomPedStreamSyncedMeta

Re-exports ICustomPedStreamSyncedMeta

ICustomPedSyncedMeta

Re-exports ICustomPedSyncedMeta

ICustomPlayerLocalMeta

Re-exports ICustomPlayerLocalMeta

ICustomPlayerStreamSyncedMeta

Re-exports ICustomPlayerStreamSyncedMeta

ICustomPlayerSyncedMeta

Re-exports ICustomPlayerSyncedMeta

ICustomServerClientEvent

Re-exports ICustomServerClientEvent

ICustomServerClientRpc

Re-exports ICustomServerClientRpc

ICustomVehicleStreamSyncedMeta

Re-exports ICustomVehicleStreamSyncedMeta

ICustomVehicleSyncedMeta

Re-exports ICustomVehicleSyncedMeta

ICustomVirtualEntityStreamSyncedMeta

Re-exports ICustomVirtualEntityStreamSyncedMeta

IInspectOptions

Re-exports IInspectOptions

IQuaternion

Re-exports IQuaternion

IResource

Re-exports IResource

IResourceConfig

Re-exports IResourceConfig

IVector2

Re-exports IVector2

IVector3

Re-exports IVector3

IWeapon

Re-exports IWeapon

KeyCode

Re-exports KeyCode

MarkerType

Re-exports MarkerType

ModelType

Re-exports ModelType

PedConfigFlag

Re-exports PedConfigFlag

Permission

Re-exports Permission

Quaternion

Re-exports Quaternion

RGBA

Re-exports RGBA

Resource

Re-exports Resource

Utils

Re-exports Utils

Vector2

Re-exports Vector2

Vector3

Re-exports Vector3

VehicleLockState

Re-exports VehicleLockState

VoiceConnectionState

Re-exports VoiceConnectionState

branch

Re-exports branch

clearEveryTick

Re-exports clearEveryTick

clearInterval

Re-exports clearInterval

clearNextTick

Re-exports clearNextTick

clearTimeout

Re-exports clearTimeout

debug

Re-exports debug

defaultDimension

Re-exports defaultDimension

deleteMeta

Re-exports deleteMeta

emit

Re-exports emit

emitRaw

Re-exports emitRaw

everyTick

Re-exports everyTick

getAllResources

Re-exports getAllResources

getEventListeners

Re-exports getEventListeners

getMeta

Re-exports getMeta

getMetaKeys

Re-exports getMetaKeys

getNetTime

Re-exports getNetTime

getSyncedMeta

Re-exports getSyncedMeta

getSyncedMetaKeys

Re-exports getSyncedMetaKeys

getVoiceConnectionState

Re-exports getVoiceConnectionState

globalDimension

Re-exports globalDimension

hasMeta

Re-exports hasMeta

hasResource

Re-exports hasResource

hasSyncedMeta

Re-exports hasSyncedMeta

hash

Re-exports hash

isClient

Re-exports isClient

isServer

Re-exports isServer

log

Re-exports log

logDebug

Re-exports logDebug

logError

Re-exports logError

logWarning

Re-exports logWarning

nextTick

Re-exports nextTick

off

Re-exports off

on

Re-exports on

once

Re-exports once

resourceName

Re-exports resourceName

sdkVersion

Re-exports sdkVersion

setInterval

Re-exports setInterval

setMeta

Re-exports setMeta

setTimeout

Re-exports setTimeout

stringToSHA256

Re-exports stringToSHA256

time

Re-exports time

timeEnd

Re-exports timeEnd

version

Re-exports version

Functions

addGxtText

  • addGxtText(key: string | number, value: string): void
  • Adds a new GXT entry with the specified value.

    remarks

    The GXT entry FE_THDR_GTAO is locked and cannot be changed.

    Parameters

    • key: string | number

      GXT entry name or hash.

    • value: string

      GXT entry value.

    Returns void

addVoiceFilter

  • addVoiceFilter(player: number, filter: AudioFilter): void
  • Parameters

    Returns void

beginScaleformMovieMethodMinimap

  • beginScaleformMovieMethodMinimap(methodName: string): boolean
  • Executes the specified scaleform method on the minimap.

    Parameters

    • methodName: string

    Returns boolean

clearPedProp

  • clearPedProp(scriptID: number, component: number): void
  • Removes a specified prop component from a ped.

    Parameters

    • scriptID: number

      ScriptID of the Ped.

    • component: number

      Component id of the prop.

    Returns void

copyToClipboard

  • copyToClipboard(val: string): void
  • Copy content into users clipboard.

    remarks

    This function requires Clipboard Access permission from the user.

    Parameters

    • val: string

    Returns void

doesConfigFlagExist

  • doesConfigFlagExist(flag: string): boolean
  • Returns whether the specified config flag exists.

    Parameters

    • flag: string

      Config flag name.

    Returns boolean

    True when the config flag exists.

emit

  • emit<K>(eventName: K, ...args: Parameters<ICustomEmitEvent[K]>): void
  • emit<K>(eventName: Exclude<K, keyof IClientEvent | keyof ICustomEmitEvent>, ...args: any[]): void
  • Emits specified event across resources.

    Type parameters

    Parameters

    • eventName: K
    • Rest ...args: Parameters<ICustomEmitEvent[K]>

      Rest parameters for emit to send.

    Returns void

  • Type parameters

    • K: string

    Parameters

    Returns void

emitRaw

  • emitRaw<K>(eventName: K, ...args: Parameters<ICustomEmitEvent[K]>): void
  • emitRaw<K>(eventName: Exclude<K, keyof IClientEvent | keyof ICustomEmitEvent>, ...args: any[]): void
  • Emits specified event across resources.

    remarks

    Works only from JS resource to JS resource

    Type parameters

    Parameters

    • eventName: K

      Name of the event.

    • Rest ...args: Parameters<ICustomEmitEvent[K]>

      Rest parameters for emit to send.

    Returns void

  • Type parameters

    • K: string

    Parameters

    Returns void

emitRpc

  • emitRpc<K>(rpcName: K, ...args: Parameters<ICustomClientServerRpc[K]>): Promise<ReturnType<ICustomClientServerRpc[K]>>
  • emitRpc<K>(rpcName: Exclude<K, keyof ICustomClientServerRpc>, ...args: any[]): Promise<any>
  • Calls a server sided RPC with the specified arguments.

    example
    alt.on("consoleCommand", async (cmd) => {
        if (cmd !== "rpc") return;
    
        try {
            const result = await alt.emitRpc("testRpc");
    
            alt.log("Rpc result:", ...result);
       }
       catch (err) {
           alt.logError(`Failed to call rpc: ${err}`);
       }
    });
    
    remarks

    Exceptions will be thrown when there was an error on server-side.

    Type parameters

    Parameters

    • rpcName: K

      Name of the RPC

    • Rest ...args: Parameters<ICustomClientServerRpc[K]>

    Returns Promise<ReturnType<ICustomClientServerRpc[K]>>

  • Type parameters

    • K: string

    Parameters

    Returns Promise<any>

emitServer

  • emitServer<K>(eventName: K, ...args: Parameters<ICustomClientServerEvent[K]>): void
  • emitServer<K>(eventName: Exclude<K, keyof ICustomClientServerEvent>, ...args: any[]): void
  • Emits specified event to server.

    Type parameters

    Parameters

    • eventName: K

      Name of the event.

    • Rest ...args: Parameters<ICustomClientServerEvent[K]>

      Rest parameters for emit to send.

    Returns void

  • Type parameters

    • K: string

    Parameters

    Returns void

emitServerRaw

  • emitServerRaw<K>(eventName: K, ...args: Parameters<ICustomClientServerEvent[K]>): void
  • emitServerRaw<K>(eventName: Exclude<K, keyof ICustomClientServerEvent>, ...args: any[]): void
  • Emits specified event to server.

    remarks

    Works only from JS (Client) to JS (Server)

    Type parameters

    Parameters

    • eventName: K

      Name of the event.

    • Rest ...args: Parameters<ICustomClientServerEvent[K]>

      Rest parameters for emit to send.

    Returns void

  • Type parameters

    • K: string

    Parameters

    Returns void

emitServerUnreliable

  • emitServerUnreliable<K>(eventName: K, ...args: Parameters<ICustomClientServerEvent[K]>): void
  • emitServerUnreliable<K>(eventName: Exclude<K, keyof ICustomClientServerEvent>, ...args: any[]): void
  • Emits specified event to server.

    remarks

    Unreliable event should be used when you don't need to be sure that event will be received by server.

    Type parameters

    Parameters

    • eventName: K

      Name of the event.

    • Rest ...args: Parameters<ICustomClientServerEvent[K]>

      Rest parameters for emit to send.

    Returns void

  • Type parameters

    • K: string

    Parameters

    Returns void

evalModule

  • evalModule(code: string): Record<string, any>
  • Evaluates and executes the given JavaScript code.

    remarks

    The code is evaluated in its own context, so it cannot access variables, functions etc. from the calling file.

    Parameters

    • code: string

      The JavaScript code.

    Returns Record<string, any>

    The exports of the evaluated module.

gameControlsEnabled

  • gameControlsEnabled(): boolean
  • Returns whether the game controls are currently enabled.

    Returns boolean

getCamPos

  • Returns Vector3

getConfigFlag

  • getConfigFlag(flag: ConfigFlag): boolean
  • getConfigFlag(flag: "DISABLE_AUTO_WEAPON_SWAP" | "DISABLE_PED_PROP_KNOCK_OFF" | "DISABLE_IDLE_CAMERA" | "DISABLE_VEHICLE_ENGINE_SHUTDOWN_ON_LEAVE" | "DISABLE_SP_ENTER_VEHICLE_CLIPSET" | "FORCE_RENDER_SNOW" | "FORCE_HIDE_NIGHT_PROPS" | "FORCE_SHOW_NIGHT_PROPS" | "DISABLE_EMISSIVE_LIGHTS_RENDERING" | "FORCE_VEHICLE_TYRE_BURST"): boolean
  • Returns the state of the specified ped config flag of the local player.

    Parameters

    Returns boolean

    State of the specified config flag.

  • Parameters

    • flag: "DISABLE_AUTO_WEAPON_SWAP" | "DISABLE_PED_PROP_KNOCK_OFF" | "DISABLE_IDLE_CAMERA" | "DISABLE_VEHICLE_ENGINE_SHUTDOWN_ON_LEAVE" | "DISABLE_SP_ENTER_VEHICLE_CLIPSET" | "FORCE_RENDER_SNOW" | "FORCE_HIDE_NIGHT_PROPS" | "FORCE_SHOW_NIGHT_PROPS" | "DISABLE_EMISSIVE_LIGHTS_RENDERING" | "FORCE_VEHICLE_TYRE_BURST"

    Returns boolean

getCursorPos

  • getCursorPos(normalized?: boolean): Vector2
  • Gets the current position of the cursor.

    Parameters

    • Optional normalized: boolean

      If true returns coordinates that are in the range 0 to 1. Defaults to false.

    Returns Vector2

getFps

  • getFps(): number
  • Represents the current client fps.

    Returns number

getGxtText

  • getGxtText(key: string | number): string | null
  • Gets the value of the specified GXT entry.

    Parameters

    • key: string | number

      GXT entry name.

    Returns string | null

getHeadshotBase64

  • getHeadshotBase64(id: number): string
  • Gets the Base64 encoded string of the headshot with the specified ID.

    remarks

    The headshot ID is returned by the registerPedheadshot3, registerPedheadshotTransparent or registerPedheadshot native.

    Parameters

    • id: number

      ID of the headshot.

    Returns string

    The Base64 string of the headshot image.

getLicenseHash

  • getLicenseHash(): string
  • Returns string

getLocalMeta

  • getLocalMeta<K>(key: Exclude<K, keyof ICustomPlayerLocalMeta>): unknown
  • getLocalMeta<K>(key: K): ICustomPlayerLocalMeta[K] | undefined
  • getLocalMeta<V>(key: string): V | undefined
  • Gets a value using the specified key.

    Type parameters

    • K: string

    Parameters

    Returns unknown

    Dynamic value associated with the specified key or undefined if no data is present.

  • Type parameters

    Parameters

    • key: K

    Returns ICustomPlayerLocalMeta[K] | undefined

  • Type parameters

    • V: any

    Parameters

    • key: string

    Returns V | undefined

getLocale

  • getLocale(): Locale
  • getLocale(): "id" | "th" | "tr" | "ar" | "by" | "cz" | "de" | "en" | "es" | "fa" | "fr" | "he" | "hu" | "in_hd" | "in_ml" | "in_tl" | "in_tm" | "it" | "lt" | "lv" | "nb_no" | "nn_no" | "pl" | "pt" | "pt_br" | "ro" | "rs" | "ru" | "sk" | "ua" | "zh_cn" | "zh_tw"
  • Gets the current alt:V locale.

    Returns Locale

  • Returns "id" | "th" | "tr" | "ar" | "by" | "cz" | "de" | "en" | "es" | "fa" | "fr" | "he" | "hu" | "in_hd" | "in_ml" | "in_tl" | "in_tm" | "it" | "lt" | "lv" | "nb_no" | "nn_no" | "pl" | "pt" | "pt_br" | "ro" | "rs" | "ru" | "sk" | "ua" | "zh_cn" | "zh_tw"

getMsPerGameMinute

  • getMsPerGameMinute(): number
  • Gets the current milliseconds per game minute.

    remarks

    This is set with the setMsPerGameMinute function.

    Returns number

getPedBonePos

  • getPedBonePos(ped: number, boneId: number): Vector3
  • Parameters

    • ped: number
    • boneId: number

    Returns Vector3

getPermissionState

  • getPermissionState(permId: Permission): boolean
  • getPermissionState<T>(permId: T): boolean
  • Gets the state of the specified permission.

    Parameters

    Returns boolean

    Permission state.

  • Type parameters

    • T: number

    Parameters

    • permId: T

    Returns boolean

getPing

  • getPing(): number
  • Represents the current client ping.

    Returns number

getPoolCount

  • getPoolCount(poolName: string): number
  • Parameters

    • poolName: string

    Returns number

getPoolEntities

  • getPoolEntities(poolName: string): number[]
  • Parameters

    • poolName: string

    Returns number[]

getPoolSize

  • getPoolSize(poolName: string): number
  • Parameters

    • poolName: string

    Returns number

getRemoteEventListeners

  • getRemoteEventListeners(eventName: string | null): readonly ((...args: any[]) => void)[]
  • Gets all the listeners that have been subscribed using onServer for the specified remote event.

    Parameters

    • eventName: string | null

      Name of the event or null for generic event.

    Returns readonly ((...args: any[]) => void)[]

    Array of listener functions for that event.

getScreenResolution

  • Returns Vector2

getServerIp

  • getServerIp(): string
  • Gets the ip adress of the server where you are connected to.

    Returns string

    The server ip.

getServerPort

  • getServerPort(): number
  • Gets the port of the server where you are connected to.

    Returns number

    The server port.

getServerTime

  • getServerTime(): number
  • Gets current server time since epoch in milliseconds.

    Returns number

getStat

  • getStat(statName: StatName): number
  • getStat(statName: "stamina" | "strength" | "lung_capacity" | "wheelie_ability" | "flying_ability" | "shooting_ability" | "stealth_ability"): number
  • Gets a value of the specified statistic.

    Parameters

    • statName: StatName

      Name of the statistic.

    Returns number

  • Parameters

    • statName: "stamina" | "strength" | "lung_capacity" | "wheelie_ability" | "flying_ability" | "shooting_ability" | "stealth_ability"

    Returns number

getTotalPacketsLost

  • getTotalPacketsLost(): bigint
  • Returns bigint

getTotalPacketsSent

  • getTotalPacketsSent(): bigint
  • Returns bigint

getVoiceFilter

  • Parameters

    • player: number

    Returns AudioFilter

getVoiceNonSpatialVolume

  • getVoiceNonSpatialVolume(player: number): number
  • Parameters

    • player: number

    Returns number

getVoicePlayers

  • getVoicePlayers(): number[]
  • Returns number[]

getVoiceSpatialVolume

  • getVoiceSpatialVolume(player: number): number
  • Parameters

    • player: number

    Returns number

hasLocalMeta

  • hasLocalMeta(key: string): boolean
  • hasLocalMeta<K>(key: K): boolean
  • Parameters

    • key: string

    Returns boolean

  • Type parameters

    Parameters

    • key: K

    Returns boolean

isCamFrozen

  • isCamFrozen(): boolean
  • Returns boolean

isConsoleOpen

  • isConsoleOpen(): boolean
  • Returns state of console window.

    Returns boolean

    True when console window is opened.

isCursorVisible

  • isCursorVisible(): boolean
  • Returns boolean

isFullScreen

  • isFullScreen(): boolean
  • Returns boolean

isGameFocused

  • isGameFocused(): boolean
  • Returns state of game window.

    Returns boolean

    True when game window is focused.

isInStreamerMode

  • isInStreamerMode(): boolean
  • Returns if alt:V is in streamer mode.

    Returns boolean

    True when alt:V client is launched in streamer mode.

isKeyDown

  • Determines whether the specified key is pressed.

    Parameters

    Returns boolean

isKeyToggled

  • isKeyToggled(key: KeyCode): boolean
  • Returns whether the specified key is toggled.

    Parameters

    Returns boolean

isMenuOpen

  • isMenuOpen(): boolean
  • Returns state of user interface and console window.

    Returns boolean

    True when user interface or console window is opened.

isPointOnScreen

  • isPointOnScreen(x: number, y: number, z: number): boolean
  • isPointOnScreen(value: IVector3): boolean
  • Parameters

    • x: number
    • y: number
    • z: number

    Returns boolean

  • Parameters

    Returns boolean

isTextureExistInArchetype

  • isTextureExistInArchetype(modelHash: number, targetTextureName: string): boolean
  • Parameters

    • modelHash: number
    • targetTextureName: string

    Returns boolean

loadDefaultIpls

  • loadDefaultIpls(): void
  • Returns void

loadModel

  • loadModel(modelHash: number): void
  • Loads a model into memory synchronously.

    remarks

    Use this method only if you really need it, because this method is unsafe and can lead to game crashes. For normal model loading it is recommended to use alt.Utils.requestModel instead.

    Parameters

    • modelHash: number

      Hash of the model.

    Returns void

loadModelAsync

  • loadModelAsync(modelHash: number): void
  • Loads a model into memory asynchronously.

    remarks

    Use this method only if you really need it, because this method is unsafe and can lead to game crashes. For normal model loading it is recommended to use alt.Utils.requestModel instead.

    remarks

    If you want to know when a model is loaded use hasModelLoaded in pair with alt.Utils.waitFor.

    Parameters

    • modelHash: number

      Hash of the model.

    Returns void

loadRmlFont

  • loadRmlFont(path: string, name: string, italic?: boolean, bold?: boolean): void
  • Parameters

    • path: string
    • name: string
    • Optional italic: boolean
    • Optional bold: boolean

    Returns void

loadYtyp

  • loadYtyp(path: string): boolean
  • Load a specific ytyp file.

    example
    alt.loadYtyp("x64u.rpf/levels/gta5/_hills/country_06/country_06_metadata.rpf/cs6_08_interior_cs6_08_mine_int.ytyp")
    

    Parameters

    • path: string

      Relative path to the game folder.

    Returns boolean

off

  • Unsubscribes from a event with the specified listener.

    remarks

    Listener should be of the same reference as when event was subscribed to.

    Type parameters

    Parameters

    Returns void

  • Type parameters

    • K: string

    Parameters

    • eventName: Exclude<K, keyof IClientEvent | keyof ICustomEmitEvent>
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns void

offRpc

  • offRpc<K>(rpcName: K, listener?: (...args: Parameters<ICustomServerClientRpc[K]>) => Promise<ReturnType<ICustomServerClientRpc[K]>> | ReturnType<ICustomServerClientRpc[K]>): void
  • offRpc<K>(rpcName: Exclude<K, keyof ICustomServerClientRpc>, listener?: (...args: any[]) => Promise<any> | any): void
  • Type parameters

    Parameters

    • rpcName: K

      Name of the RPC

    • Optional listener: (...args: Parameters<ICustomServerClientRpc[K]>) => Promise<ReturnType<ICustomServerClientRpc[K]>> | ReturnType<ICustomServerClientRpc[K]>

      Listener that should be removed (if not passed current listener will be removed).

        • (...args: Parameters<ICustomServerClientRpc[K]>): Promise<ReturnType<ICustomServerClientRpc[K]>> | ReturnType<ICustomServerClientRpc[K]>
        • Parameters

          • Rest ...args: Parameters<ICustomServerClientRpc[K]>

          Returns Promise<ReturnType<ICustomServerClientRpc[K]>> | ReturnType<ICustomServerClientRpc[K]>

    Returns void

  • Type parameters

    • K: string

    Parameters

    • rpcName: Exclude<K, keyof ICustomServerClientRpc>
    • Optional listener: (...args: any[]) => Promise<any> | any
        • (...args: any[]): Promise<any> | any
        • Parameters

          • Rest ...args: any[]

          Returns Promise<any> | any

    Returns void

offServer

  • offServer<K>(eventName: K, listener: (...args: Parameters<ICustomServerClientEvent[K]>) => void): void
  • offServer<K>(eventName: Exclude<K, keyof ICustomServerClientEvent>, listener: (...args: any[]) => void): void
  • offServer(eventName: string, listener: (...args: any[]) => void): void
  • offServer(listener: (eventName: string, ...args: any[]) => void): void
  • Unsubscribes from a server event with the specified listener.

    remarks

    Listener should be of the same reference as when event was subscribed to.

    Type parameters

    Parameters

    • eventName: K

      Name of the event.

    • listener: (...args: Parameters<ICustomServerClientEvent[K]>) => void

      Listener that should be removed.

        • (...args: Parameters<ICustomServerClientEvent[K]>): void
        • Parameters

          • Rest ...args: Parameters<ICustomServerClientEvent[K]>

          Returns void

    Returns void

  • Type parameters

    • K: string

    Parameters

    • eventName: Exclude<K, keyof ICustomServerClientEvent>
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns void

  • Parameters

    • eventName: string
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns void

  • Unsubscribes from all user-created server events with the specified listener.

    remarks

    Listener should be of the same reference as when event was subscribed to.

    Parameters

    • listener: (eventName: string, ...args: any[]) => void

      Listener that should be removed.

        • (eventName: string, ...args: any[]): void
        • Parameters

          • eventName: string
          • Rest ...args: any[]

          Returns void

    Returns void

on

  • Subscribes to a client event with the specified listener.

    Type parameters

    Parameters

    Returns void

  • Type parameters

    • K: string

    Parameters

    • eventName: Exclude<K, keyof IClientEvent | keyof ICustomEmitEvent>
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns void

onRpc

  • onRpc<K>(rpcName: K, listener: (...args: Parameters<ICustomServerClientRpc[K]>) => Promise<ReturnType<ICustomServerClientRpc[K]>> | ReturnType<ICustomServerClientRpc[K]>): void
  • onRpc<K>(rpcName: Exclude<K, keyof ICustomServerClientRpc>, listener: (...args: any[]) => Promise<any> | any): void
  • Subscribes to a server -> client RPC with the specified listener.

    remarks

    The return value of the listener function determines the response server will receive. When returning multiple values, use an array. Returning an Error object will cause the promise on the server to throw an exception which has to be caught.

    Type parameters

    Parameters

    • rpcName: K

      Name of the RPC

    • listener: (...args: Parameters<ICustomServerClientRpc[K]>) => Promise<ReturnType<ICustomServerClientRpc[K]>> | ReturnType<ICustomServerClientRpc[K]>

      Listener to be assigned to this RPC name (there can only be one listener for each RPC name).

      • @example

        alt.onRpc("testRpc", (...args) => {
          alt.log(`server called testRpc`, args);
        
         // throw new Error("I am an error! Notice me!");
         return [1, 2, [10, 13, 19], false, "hey there"];
        });
        
        • (...args: Parameters<ICustomServerClientRpc[K]>): Promise<ReturnType<ICustomServerClientRpc[K]>> | ReturnType<ICustomServerClientRpc[K]>
        • Parameters

          • Rest ...args: Parameters<ICustomServerClientRpc[K]>

          Returns Promise<ReturnType<ICustomServerClientRpc[K]>> | ReturnType<ICustomServerClientRpc[K]>

    Returns void

  • Type parameters

    • K: string

    Parameters

    • rpcName: Exclude<K, keyof ICustomServerClientRpc>
    • listener: (...args: any[]) => Promise<any> | any
        • (...args: any[]): Promise<any> | any
        • Parameters

          • Rest ...args: any[]

          Returns Promise<any> | any

    Returns void

onServer

  • onServer<K>(eventName: K, listener: (...args: Parameters<ICustomServerClientEvent[K]>) => void): void
  • onServer<K>(eventName: Exclude<K, keyof ICustomServerClientEvent>, listener: (...args: any[]) => void): void
  • onServer(listener: (eventName: string, ...args: any[]) => void): void
  • Subscribes to a server event with the specified listener.

    Type parameters

    Parameters

    • eventName: K

      Name of the event.

    • listener: (...args: Parameters<ICustomServerClientEvent[K]>) => void

      Listener that should be added.

        • (...args: Parameters<ICustomServerClientEvent[K]>): void
        • Parameters

          • Rest ...args: Parameters<ICustomServerClientEvent[K]>

          Returns void

    Returns void

  • Type parameters

    • K: string

    Parameters

    • eventName: Exclude<K, keyof ICustomServerClientEvent>
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns void

  • Parameters

    • listener: (eventName: string, ...args: any[]) => void
        • (eventName: string, ...args: any[]): void
        • Parameters

          • eventName: string
          • Rest ...args: any[]

          Returns void

    Returns void

once

  • Subscribes to a client event with the specified listener, which only triggers once.

    Type parameters

    Parameters

    Returns void

  • Type parameters

    • K: string

    Parameters

    • eventName: Exclude<K, keyof IClientEvent | keyof ICustomEmitEvent>
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns void

onceServer

  • onceServer<K>(eventName: K, listener: (...args: Parameters<ICustomServerClientEvent[K]>) => void): void
  • onceServer<K>(eventName: Exclude<K, keyof ICustomServerClientEvent>, listener: (...args: any[]) => void): void
  • onceServer(listener: (eventName: string, ...args: any[]) => void): void
  • Subscribes to a server event with the specified listener, which only triggers once.

    Type parameters

    Parameters

    • eventName: K

      Name of the event.

    • listener: (...args: Parameters<ICustomServerClientEvent[K]>) => void

      Listener that should be added.

        • (...args: Parameters<ICustomServerClientEvent[K]>): void
        • Parameters

          • Rest ...args: Parameters<ICustomServerClientEvent[K]>

          Returns void

    Returns void

  • Type parameters

    • K: string

    Parameters

    • eventName: Exclude<K, keyof ICustomServerClientEvent>
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns void

  • Subscribes to all server events with the specified listener, which only triggers once.

    remarks

    Listener will be only called for user-created events.

    Parameters

    • listener: (eventName: string, ...args: any[]) => void

      Listener that should be added.

        • (eventName: string, ...args: any[]): void
        • Parameters

          • eventName: string
          • Rest ...args: any[]

          Returns void

    Returns void

removeGxtText

  • removeGxtText(key: string): void
  • Removes the specified GXT entry.

    Parameters

    • key: string

      GXT entry name.

    Returns void

removeIpl

  • removeIpl(iplName: string): void
  • Unloads the specified ipl.

    Parameters

    • iplName: string

      Name of the ipl.

    Returns void

removeVoiceFilter

  • removeVoiceFilter(player: number): void
  • Parameters

    • player: number

    Returns void

removeVoicePlayer

  • removeVoicePlayer(player: number): void
  • Parameters

    • player: number

    Returns void

requestIpl

  • requestIpl(iplName: string): void
  • Loads the specified ipl.

    Parameters

    • iplName: string

      Name of the ipl.

    Returns void

resetMinimapComponentPosition

  • resetMinimapComponentPosition(name: string): void
  • Reset minimap default component position.

    Parameters

    • name: string

      Name of the minimap component.

    Returns void

resetStat

  • resetStat(statName: StatName): void
  • resetStat(statName: "stamina" | "strength" | "lung_capacity" | "wheelie_ability" | "flying_ability" | "shooting_ability" | "stealth_ability"): void
  • Resets a statistic to its default value.

    Parameters

    • statName: StatName

      Name of the statistic.

    Returns void

  • Parameters

    • statName: "stamina" | "strength" | "lung_capacity" | "wheelie_ability" | "flying_ability" | "shooting_ability" | "stealth_ability"

    Returns void

rmlControlsEnabled

  • rmlControlsEnabled(): boolean
  • Returns boolean

screenToWorld

  • Converts screen coordinates to world position

    Parameters

    • x: number
    • y: number

    Returns Vector3

  • Parameters

    Returns Vector3

setCamFrozen

  • setCamFrozen(state: boolean): void
  • Freezes the camera in place so it doesn't change position or rotation.

    remarks

    You can still move your character even if your camera is frozen.

    Parameters

    • state: boolean

      True to freeze the camera, false to unfreeze the camera.

    Returns void

setConfigFlag

  • setConfigFlag(flag: ConfigFlag, state: boolean): void
  • setConfigFlag(flag: "DISABLE_AUTO_WEAPON_SWAP" | "DISABLE_PED_PROP_KNOCK_OFF" | "DISABLE_IDLE_CAMERA" | "DISABLE_VEHICLE_ENGINE_SHUTDOWN_ON_LEAVE" | "DISABLE_SP_ENTER_VEHICLE_CLIPSET" | "FORCE_RENDER_SNOW" | "FORCE_HIDE_NIGHT_PROPS" | "FORCE_SHOW_NIGHT_PROPS" | "DISABLE_EMISSIVE_LIGHTS_RENDERING" | "FORCE_VEHICLE_TYRE_BURST", state: boolean): void
  • Sets the specified ped config flag of the local player to the specified state.

    Parameters

    • flag: ConfigFlag

      Config flag name.

    • state: boolean

      Config flag state.

    Returns void

  • Parameters

    • flag: "DISABLE_AUTO_WEAPON_SWAP" | "DISABLE_PED_PROP_KNOCK_OFF" | "DISABLE_IDLE_CAMERA" | "DISABLE_VEHICLE_ENGINE_SHUTDOWN_ON_LEAVE" | "DISABLE_SP_ENTER_VEHICLE_CLIPSET" | "FORCE_RENDER_SNOW" | "FORCE_HIDE_NIGHT_PROPS" | "FORCE_SHOW_NIGHT_PROPS" | "DISABLE_EMISSIVE_LIGHTS_RENDERING" | "FORCE_VEHICLE_TYRE_BURST"
    • state: boolean

    Returns void

setCursorPos

  • setCursorPos(pos: IVector2, normalized?: boolean): void
  • Sets the current position of the cursor.

    remarks

    The cursor has to be visible for this to take effect.

    Parameters

    • pos: IVector2
    • Optional normalized: boolean

    Returns void

setMinimapComponentPosition

  • setMinimapComponentPosition(name: string, alignX: string, alignY: string, pos: IVector2, size: IVector2): void
  • setMinimapComponentPosition(name: string, alignX: string, alignY: string, posX: number, posY: number, sizeX: number, sizeY: number): void
  • Modify minimap component position.

    Parameters

    • name: string

      Name of the minimap component.

    • alignX: string

      Same as alignX field in fontend.xml.

    • alignY: string

      Same as alignY field in fontend.xml.

    • pos: IVector2

      Same as posX and posY field in fontend.xml.

    • size: IVector2

      Same as sizeX and sizeY field in fontend.xml.

    Returns void

  • Modify minimap component position.

    Parameters

    • name: string

      Name of the minimap component.

    • alignX: string

      Same as alignX field in fontend.xml.

    • alignY: string

      Same as alignY field in fontend.xml.

    • posX: number

      Same as posX field in fontend.xml.

    • posY: number

      Same as posY field in fontend.xml.

    • sizeX: number

      Same as sizeX field in fontend.xml.

    • sizeY: number

      Same as sizeY field in fontend.xml.

    Returns void

setMinimapIsRectangle

  • setMinimapIsRectangle(state: boolean): void
  • Defines if the minimap is a rectangle to change the blip clipping.

    Parameters

    • state: boolean

      False will clip the blips rounded to the minimap.

    Returns void

setMsPerGameMinute

  • setMsPerGameMinute(milliseconds: number): void
  • Sets the amount of real milliseconds that have to pass every game minute.

    Parameters

    • milliseconds: number

    Returns void

setPedDlcClothes

  • setPedDlcClothes(scriptID: number, dlc: number, component: number, drawable: number, texture: number, palette?: number): void
  • Sets the specified dlc clothing component to a ped.

    Parameters

    • scriptID: number

      ScriptID of the Ped.

    • dlc: number

      Dlc hash of the clothing.

    • component: number

      Component id of the clothing.

    • drawable: number

      Drawable id of the clothing.

    • texture: number

      Texture id of the clothing.

    • Optional palette: number

      Palette of the clothing.

    Returns void

setPedDlcProp

  • setPedDlcProp(scriptID: number, dlc: number, component: number, drawable: number, texture: number): void
  • Sets the specified dlc prop component to a ped.

    Parameters

    • scriptID: number

      ScriptID of the Ped.

    • dlc: number

      Dlc hash of the prop.

    • component: number

      Component id of the prop.

    • drawable: number

      Drawable id of the prop.

    • texture: number

      Texture id of the prop.

    Returns void

setRotationVelocity

  • setRotationVelocity(scriptID: number, x: number, y: number, z: number): void
  • Sets the rotation velocity for the specified entity.

    Parameters

    • scriptID: number

      The script id of the entity.

    • x: number

      The rotation velocity on the X axis.

    • y: number

      The rotation velocity on the Y axis.

    • z: number

      The rotation velocity on the Z axis.

    Returns void

setStat

  • setStat(statName: StatName, value: number): void
  • setStat(statName: "stamina" | "strength" | "lung_capacity" | "wheelie_ability" | "flying_ability" | "shooting_ability" | "stealth_ability", value: number): void
  • Sets a statistic to desired value.

    Parameters

    • statName: StatName

      Name of the statistic.

    • value: number

      Value of the statistic you want to set.

    Returns void

  • Parameters

    • statName: "stamina" | "strength" | "lung_capacity" | "wheelie_ability" | "flying_ability" | "shooting_ability" | "stealth_ability"
    • value: number

    Returns void

setVoiceNonSpatialVolume

  • setVoiceNonSpatialVolume(player: number, volume: number): void
  • Parameters

    • player: number
    • volume: number

    Returns void

setVoiceSpatialVolume

  • setVoiceSpatialVolume(player: number, volume: number): void
  • Parameters

    • player: number
    • volume: number

    Returns void

setWatermarkPosition

  • setWatermarkPosition(position: WatermarkPosition): void
  • setWatermarkPosition<T>(position: T): void
  • Change the position of the alt:V watermark.

    deprecated

    This method will be removed in the next major release. (v17)

    Parameters

    Returns void

  • deprecated

    This method will be removed in the next major release. (v17)

    Type parameters

    • T: number

    Parameters

    • position: T

    Returns void

setWeatherCycle

  • setWeatherCycle(weathers: number[], multipliers: number[]): void
  • Sets the current weather cycle.

    remarks

    This has to be activated after using it by using the setWeatherSyncActive function. The weathers and multipliers array has to be of the same length.

    Parameters

    • weathers: number[]

      An array containing the weather ids for the weather cycle.

    • multipliers: number[]

      An array containing the multipliers for the weather cycle.

    Returns void

setWeatherSyncActive

  • setWeatherSyncActive(isActive: boolean): void
  • Sets whether the weather sync is active.

    remarks

    The weather sync has to be set by using the setWeatherCycle function.

    Parameters

    • isActive: boolean

      Whether the weather sync should be active.

    Returns void

showCursor

  • showCursor(state: boolean): void
  • Changes the visibility of cursor.

    remarks

    This is handled by resource scoped internal integer, which gets increased/decreased by every function call. When you show your cursor 5 times, to hide it you have to do that 5 times accordingly.

    Parameters

    • state: boolean

      A boolean indicating whenever cursor should be visible or not.

    Returns void

takeScreenshot

  • takeScreenshot(): Promise<string>
  • The output is returned as a base64 string.

    remarks

    This function requires Screen Capture permission from the user.

    Returns Promise<string>

    Return is dependent on the success of the operation.

takeScreenshotGameOnly

  • takeScreenshotGameOnly(): Promise<string>
  • The output is returned as a base64 string.

    remarks

    This only takes a screenshot of the raw GTA:V window. WebViews, game overlays etc. won't be captured. This function requires Screen Capture permission from the user.

    Returns Promise<string>

    Return is dependent on the success of the operation.

toggleGameControls

  • toggleGameControls(state: boolean): void
  • Toggles the game controls.

    remarks

    When this is set to false, all controls are disabled, so you can't move your character or the camera.

    Parameters

    • state: boolean

      True to enable controls, false to disable controls.

    Returns void

toggleRmlControls

  • toggleRmlControls(state: boolean): void
  • Parameters

    • state: boolean

    Returns void

toggleVoiceControls

  • toggleVoiceControls(state: boolean): void
  • Parameters

    • state: boolean

    Returns void

unloadYtyp

  • unloadYtyp(path: string): boolean
  • Unload a specific ytyp file.

    example
    alt.unloadYtyp("x64u.rpf/levels/gta5/_hills/country_06/country_06_metadata.rpf/cs6_08_interior_cs6_08_mine_int.ytyp")
    

    Parameters

    • path: string

      Relative path to the game folder.

    Returns boolean

updateClipContext

  • updateClipContext(context: Record<string, string>): void
  • Parameters

    • context: Record<string, string>

    Returns void

worldToScreen

  • Converts the world position into screen coordinates

    Parameters

    • x: number
    • y: number
    • z: number

    Returns Vector3

    Screen coordinates as x, y and z as depth

  • Parameters

    Returns Vector3