Skip to content

Latest commit

 

History

History
111 lines (73 loc) · 1.69 KB

README.md

File metadata and controls

111 lines (73 loc) · 1.69 KB

Banner

Front-End Utilities

Front-End utilities that facilitate add-ons development for FiveM.

Installation

Using npm:

npm install @nuxtlab/utils

Using pnpm:

pnpm install @nuxtlab/utils

Using yarn:

yarn add @nuxtlab/utils

Example Uses

You can use the examples in the subsection below to use the tools.

isEnvBrowser

  • Checks whether the development environment is a browser.
isEnvBrowser(): boolean;
  • Usage
// import

const isBrowser = isEnvBrowser()

console.log(isBrowser) // returns true if the page developed is open in the browser.

fetchNui

  • Allows you to send requests to the client side.
fetchNui(eventName: string, data: object): any;
  • Usage
// import

fetchNui('updateName', {
    name: 'Mark Edward'
})
    .then((data) => {
        console.log(data) // prints if a return was provided by the game.
    })
    .catch((error) => {
        console.log(error)
    })

useNuiEvent

  • Allows you to listen to nui callbacks.
useNuiEvent(handler: (event: { action: string, data?: object }) => void): void;
  • Usage
// import

useNuiEvent((event) => {
    console.log(event) // prints the event.
})

sendDebugEvent

  • Simulates sending a callback by the client.
sendDebugEvent(name: string, data?: object): void;
  • Usage
// import

sendDebugEvent('updateName', {
    name: 'Mark Edward'
})

Contact Us

Join our Discord Server for updates, support and special discounts!