# Exports

> In this page you will find some exports and events you can use from your external scripts to interact with av\_laptop.

{% tabs %}
{% tab title="Client" %}
### postMessage(name,data)

> Use this export to send a NUI message to your custom APP, requires to use the hook useNuiEvent() as listener.
>
> **params:**
>
> * **name**:`string` The event name.
> * **data**:`any` Data to receive
>
> ```lua
> -- EXAMPLE in the lua side
> exports['av_laptop']:postMessage("updateCrypto", 99)
> ```
>
> ```typescript
> // EXAMPLE in the Typescript side of app
> useNuiEvent('updateCrypto', (amount:number) => {
>     console.log(amount)
> })
> ```

### openApp(name,tablet)

> Open an APP directly without using the laptop item nor UI.
>
> _App name can be found in your config.lua > Config.App table > name_
>
> **params:**
>
> * **name**:`string` The app name
> * **tablet**:`boolean` Enable the tablet prop and animation
>
> **returns:**
>
> * **result**:`boolean`
>
> ```lua
> local appName = "business" -- or "cupcake" or "boosting", etc
> local opened = exports['av_laptop']:openApp(appName,true)
> print(opened)
> ```

### showLaptop(tablet,itemCheck)

> Use this export to open the laptop and set it as background while you run some other UI in front.
>
> **params:**
>
> * **tablet?** `boolean`: Enable the tablet prop and animation.
> * **itemCheck?** `boolean:` It will check if the player has the laptop item in their inventory and use the wallpaper for the interface. If the player does not have the item, it will return false and cancel the animation.
>
> ```lua
> -- Example using bl_ui minigames:
> RegisterCommand("minigame", function()
>     local hasLaptop = exports['av_laptop']:showLaptop(true,true)
>     if hasLaptop then
>         local success = exports.bl_ui:DigitDazzle(3, {
>             length = 4,
>             duration = 5000,
>         })
>         exports['av_laptop']:hideLaptop()
>     else
>         print("Player doesn't have laptop item")
>     end
> end)
> ```

<figure><img src="https://1688068901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bCwnajAqpi3Viykb5Wi%2Fuploads%2FtjU4hAbZXzndE0IFtCps%2Fimage.png?alt=media&#x26;token=122db9c5-b510-4c9d-adac-99527bf49d62" alt=""><figcaption></figcaption></figure>

**Note:** _Your minigame UI should have a z-index of 100 otherwise it will be hidden behind laptop UI._

### hideLaptop()

> Use it to close laptop when opened using showLaptop() export.
>
> ```lua
> exports['av_laptop']:hideLaptop()
> ```

### getSerial()

> Use this export to retrieve the current laptop serial.
>
> **params:**
>
> * none
>
> **returns:**
>
> * string or false
>
> ```lua
> local serial = exports['av_laptop']:getSerial()
> print(serial) -- false or string
> ```

### Wifi()

> Use this export to get the current WiFi network the laptop is connected to.
>
> **returns:**
>
> * string or nil
>
> ```lua
> local WiFi = exports['av_laptop']:WiFi()
> print(WiFi)
> ```

### refreshApps()

> Refresh the laptop apps.
>
> ```lua
> exports['av_laptop']:refreshApps()
> ```
{% endtab %}

{% tab title="Server" %}
### isReady()

> Returns true if av\_laptop is loaded and ready to be used.
>
> **returns:**
>
> * boolean
>
> ```lua
> CreateThread(function()
>     while not exports['av_laptop']:isReady() do Wait(500) end
>     print("av_laptop is ready")
> end
> ```
{% endtab %}
{% endtabs %}
