> For the complete documentation index, see [llms.txt](https://docs.av-scripts.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.av-scripts.com/laptop-pack/laptop/exports.md).

# 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="/files/h1FX7Qf7qXW0vfqWybEY" 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()
> ```

### toggle()

> Use this export to hide/show the laptop UI. This is useful when you want to open an external menu through an App and then return to the laptop. If the export is used to hide the laptop but is not called again to show it, the user will be unable to use the item, as the script will still detect the laptop as open even though it is visually hidden.
>
> {% code title="" %}
>
> ```lua
> exports['av_laptop']:toggle()
> ```
>
> {% endcode %}
> {% 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
> ```

### getSerial(playerId)

> Retrieve current laptop identifier or false if the player isn't using a laptop.
>
> **parameters:**
>
> * **playerId**:`string` Player server id
>
> **returns:**
>
> * **result**: `string|false` Laptop serial OR false if not using a laptop.
>
> ```lua
> local serial = exports['av_laptop']:getSerial(playerId)
> print(serial) -- string | false
> ```

#### hasDevice(serial,item)

> Verify if the item(s) are inside the laptop container.
>
> **params:**
>
> * **serial**:`string` Laptop serial where to look for item(s)
> * **item**:`string|table` Item name or a table with names
>
> r**eturns**
>
> * **result**:`boolean` True if the item(s) are inside laptop container
>
> ```lua
> local serial = exports['av_laptop']:getSerial(source)
> local item = "water"
> local items = {"water","pendrive", "vpn"}
> local result1 = exports['av_laptop']:hasDevice(serial, item)
> print(result1) -- example using 1 item
> local multiple = exports['av_laptop']:hasDevice(serial,items)
> print(multiple) -- example using a table with multiple item names
> ```

{% endtab %}
{% endtabs %}

.
