# APPs Config

{% hint style="warning" %}
All APPs comes enabled by default, is important that if you want to restrict the access to an APP you add your own check by using your own exports or one of the ones provided here.
{% endhint %}

### App Structure

Every **Config.App** can include the following data:

* **name**:`string` Unique app name
* **label**:`string` App label
* **isEnabled**:`function(serial)` return boolean and gives access to player
* **maximize?:**`boolean` Allows player to maximize app (false by default)
* **height?:**`string` App window height (default "80%"), it also supports pixels "300px"
* **width?:**`string` App window width (default "80%"), it also supports pixels "300px"
* **path?**:`string` Path for the .html file your resource uses for the UI rendering, this should not include the resource name, example of a valid path: `/ui/dist/index.html`

```lua
Config = {}
Config.App = {
    name = "my_app",
    label = "My App Label",
    isEnabled = function(serial)
        -- Run your own check here and return true to show the APP or false to hide it
        return true
    end,
    maximize = true, -- this is optional
    height = "490px", -- this is optional, 490px is the calculator height value
    width = "260px", -- this is optional, 260px is the calculator width value
    path = "/ui/dist/index.html" -- optional, for official AV APPS this field is not required
}
```

> The following snippets are just **examples** for most common cases, add your own checks or use other scripts exports for this.

{% tabs %}
{% tab title="Require Items" %}

> If you want to restrict an APP so only players with X item(s) can access it, you can use the following export:

```lua
Config.App = {
    name = "boosting",
    label = "Boosting",
    isEnabled = function(serial)
        return exports['av_laptop']:hasItem('water')
    end
}
```

> The export hasItem also support a table of items for situations where you want to verify if the player owns more than 1 item at the same time:

```lua
Config.App = {
    name = "boosting",
    label = "Boosting",
    isEnabled = function(serial)
        return exports['av_laptop']:hasItem({"water", "sandwich"})
    end
}
```

### Laptop Container

> If using **ox\_inventory or origen\_inventory** you can use laptop as container, this means each laptop can be used to open an individual stash:
>
> `open the inventory > right click on laptop icon > Devices`.
>
> You can drag n drop your items inside that little stash and use it to enable specific apps by using the following export:
>
> ```lua
> exports['av_laptop']:hasDevice(itemName,laptopSerial)
> ```
>
> **params:**
>
> * **itemName**:`string` Item required inside laptop container.
> * **laptopSerial**:`string` This is sent from laptop to isEnabled function
>
> **returns:**
>
> * **result**: `boolean`
>
> ```lua
> Config.App = {
>     name = "boosting",
>     label = "Boosting",
>     isEnabled = function(serial)
>         local hasDevice = exports['av_laptop']:hasDevice("black_usb", serial)
>         print("hasDevice?", hasDevice) -- should print true/false in F8
>         return hasDevice
>     end
> }
> ```

{% endtab %}

{% tab title="Job Restricted" %}

> The following example will block players with **leo job type** from accessing this app and will only allow people with X item:

<pre class="language-lua"><code class="lang-lua"><strong>Config.App = {
</strong>    name = "boosting",
    label = "Boosting", -- You can rename the app by editing this field
    isEnabled = function(serial)
        if exports['av_laptop']:hasJob("leo") then -- u can use job name or job type
            return false
        end
        return exports['av_laptop']:hasItem("water")
    end
}
</code></pre>

> With the following example only the players with ambulance job can access the app:

```lua
Config.App = {
    name = "boosting",
    label = "Boosting", -- You can rename the app by editing this field
    isEnabled = function(serial)
        return exports['av_laptop']:hasJob("ambulance")
    end
}
```

{% endtab %}

{% tab title="WiFi" %}

> We can enable APPs if the laptop is connected to a specific hotspot, in this example if the player is connected to the `uwucafe` hotspot the boosting APP will be enabled, this APP will be removed as soon as the player gets disconnected from the hotspot.

```lua
Config.App = {
    name = "boosting",
    label = "Boosting", -- You can rename the app by editing this field
    isEnabled = function(serial)
        return (exports['av_laptop']:WiFi() == "uwucafe")
    end
}
```

{% endtab %}
{% endtabs %}
