Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Utils

Hierarchy

Index

Constructors

Protected constructor

Methods

Static assert

  • assert(assertion: unknown, message?: string): assertsassertion
  • Parameters

    • assertion: unknown
    • Optional message: string

    Returns assertsassertion

Static getClosestPlayer

  • getClosestPlayer(options: { pos: IVector3; range?: number }): Player | null
  • Finds the closest player (if any) from 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.

    Parameters

    • options: { pos: IVector3; range?: number }

    Returns Player | null

Static getClosestVehicle

  • getClosestVehicle(options: { pos: IVector3; range?: number }): Vehicle | null
  • Finds the closest vehicle (if any) from 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.

    Parameters

    • options: { pos: IVector3; range?: number }

    Returns Vehicle | null

Static inspect

  • Returns a string representation of value that is intended for debugging.

    remarks

    Proxy or promise details (returned value, status) are not supported.

    Parameters

    Returns string

Static wait

  • wait(timeout: number): Promise<void>
  • Parameters

    • timeout: number

    Returns Promise<void>

Static waitFor

  • waitFor(callback: () => boolean, timeout?: number): Promise<void>
  • Waits for the callback to return true, otherwise the promise will be rejected after timeout

    Parameters

    • callback: () => boolean

      If callback returns true it resolves promise.

        • (): boolean
        • Returns boolean

    • Optional timeout: number

      The maximum milliseconds to wait, otherwise promise will be rejected. Defaults to 2000.

    Returns Promise<void>