Skip to main content

Utils

Index

Classes

Keybind

Keybind:

constructor

  • new Keybind(keyCode: KeyCode | KeyCode[], callback: () => void, eventType?: keydown | keyup): Keybind
  • Binds a callback to a specific key or multiple keys.

    Example

    // two keycodes (similar to two separate keybinds with the same handler)
    const bind = new alt.Utils.Keybind([KeyCode.G, KeyCode.H], () => {
    alt.log('pressed G or H')
    })

publicdestroy

  • destroy(): void

Marker

Marker:

A marker class whose instances do not need to be created in every tick.

Example

// Creates marker at local player pos with default options
const defaultMarker = new alt.Utils.Marker(alt.Player.local.pos);

// Creates default marker at 0, 0, 72 with red color
const redMarker = new alt.Utils.Marker(new alt.Vector3(0, 0, 72), { color: alt.RGBA.red });

// Later you can change the color, scale, etc.
redMarker.scale = new alt.Vector3(3.0); // Makes marker bigger

constructor

  • new Marker(pos: IVector3, options?: IMarkerOptions): Marker

publicbobUpAndDown

bobUpAndDown: boolean

publiccolor

color: RGBA

publicdir

dir: IVector3

publicdrawOnEnts

drawOnEnts: boolean

publicfaceCamera

faceCamera: boolean

publicp19

p19: number

publicpos

pos: IVector3

publicrot

rot: IVector3

publicrotate

rotate: boolean

publicscale

scale: IVector3

publictextureDict

textureDict: undefined | string

publictextureName

textureName: undefined | string

publictype

type: number

publicdestroy

  • destroy(): void

Functions

drawText2d

  • drawText2d(text: string, pos2d?: IVector2, font?: GameFont, scale?: number, color?: RGBA, outline?: boolean, dropShadow?: boolean, textAlign?: TextAlign): shared.Utils.EveryTick

drawText2dThisFrame

  • drawText2dThisFrame(text: string, pos2d?: IVector2, font?: GameFont, scale?: number, color?: RGBA, outline?: boolean, dropShadow?: boolean, textAlign?: TextAlign): void

drawText3d

  • drawText3d(text: string, pos3d: IVector3, font?: GameFont, scale?: number, color?: RGBA, outline?: boolean, dropShadow?: boolean, textAlign?: TextAlign): shared.Utils.EveryTick

drawText3dThisFrame

  • drawText3dThisFrame(text: string, pos3d: IVector3, font?: GameFont, scale?: number, color?: RGBA, outline?: boolean, dropShadow?: boolean, textAlign?: TextAlign): void

getClosestObject

  • getClosestObject(options?: { pos?: IVector3; range?: number }): Object | null
  • Finds the closest object (if any) from alt.Object.all.

    pos - From which position to look for the nearest object. Defaults to local player position.

    range - In which range to search for the nearest object. Defaults to Infinity.

getClosestPlayer

  • getClosestPlayer(options?: { pos?: IVector3; range?: number }): Player | null
  • Finds the closest player (if any) from alt.Player.streamedIn.

    pos - From which position to look for the nearest player. Defaults to local player position.

    range - In which range to search for the nearest player. Defaults to Infinity.

getClosestVehicle

  • getClosestVehicle(options?: { pos?: IVector3; range?: number }): Vehicle | null
  • Finds the closest vehicle (if any) from alt.Vehicle.streamedIn.

    pos - From which position to look for the nearest vehicle. Defaults to local player position.

    range - In which range to search for the nearest vehicle. Defaults to Infinity.

getClosestVirtualEntity

  • getClosestVirtualEntity(options?: { pos?: IVector3; range?: number }): VirtualEntity | null
  • Finds the closest virtualEntity (if any) from alt.VirtualEntity.streamedIn.

    pos - From which position to look for the nearest virtualEntity. Defaults to local player position.

    range - In which range to search for the nearest virtualEntity. Defaults to Infinity.

getClosestWorldObject

  • getClosestWorldObject(options?: { pos?: IVector3; range?: number }): Object | null
  • Finds the closest world object (if any) from alt.Object.allWorld.

    pos - From which position to look for the nearest world object. Defaults to local player position.

    range - In which range to search for the nearest world object. Defaults to Infinity.

loadMapArea

  • loadMapArea(pos: IVector3, radius?: number, timeout?: number): Promise<void>
  • Loads the map area at a certain position and waits asynchronously until all parts in view area have been loaded.

    Remarks

    Uses FocusData and newLoadSceneStartSphere.

registerPedheadshot3Base64

  • registerPedheadshot3Base64(ped: number | Player): Promise<string>
  • Combination of native.registerPedheadshot3 and alt.getHeadshotBase64

registerPedheadshotBase64

  • registerPedheadshotBase64(ped: number | Player): Promise<string>
  • Combination of native.registerPedheadshot and alt.getHeadshotBase64

registerPedheadshotTransparentBase64

  • registerPedheadshotTransparentBase64(ped: number | Player): Promise<string>
  • Combination of native.registerPedheadshotTransparentBase64 and alt.getHeadshotBase64

requestAnimDict

  • requestAnimDict(animDict: string, timeout?: number): Promise<void>

requestAnimSet

  • requestAnimSet(animSet: string, timeout?: number): Promise<void>

requestClipSet

  • requestClipSet(clipSet: string, timeout?: number): Promise<void>

requestCutscene

  • requestCutscene(cutsceneName: string, flags: string | number, timeout?: number): Promise<void>

requestModel

  • requestModel(model: string | number, timeout?: number): Promise<void>
  • Loads a model into memory asynchronously, like loadModelAsync but more safely.

    Remarks

    If you can’t load a specific model with this method, use loadModelAsync instead.