# Installation

## 0R SmartTab — Installation

Do the steps below (in order). This is a **tablet item** resource (inventory-based).

**Links:** Configuration · Metadata setup · Exports · 0r-dispatch setup

***

### Table of contents

1. What you need
2. Prison support (optional)
3. Copy the resource
4. Database
5. `server.cfg` load order
6. Web UI build
7. Quick configuration
8. Supported inventories & item setup
9. Giving the tablet & serials
10. Checklist
11. Troubleshooting

***

### What you need

| Requirement                 | Purpose                                                |
| --------------------------- | ------------------------------------------------------ |
| **0r\_lib**                 | Core integration, callbacks, player helpers            |
| **ox\_lib**                 | Shared utilities (`@ox_lib/init.lua` in manifest)      |
| **oxmysql**                 | MySQL access (mail, messages, MDT, bank, etc.)         |
| **xsound**                  | Music app playback                                     |
| **0r-dispatch**             | Police / MDT dispatch integration — DISPATCH\_SETUP.md |
| **One supported inventory** | Tablet item must exist there; see §6                   |
| **Node.js**                 | Only if `web/dist` is missing — used to build the NUI  |

Your framework (QBCore/Qbox/ESX/etc.) is handled by **0r\_lib** + your inventory.

***

### Prison support (optional)

Only needed if you want **Police → Prison** features.

* If you already have a jail/prison script: you’re good.
* If not: install one (e.g. **qb-prison**, **xt-prison**) that matches your framework.

***

### 1. Copy the resource

1. Copy the entire **`0r-smarttab`** folder into your server `resources` tree (e.g. `resources/[0resmon]/0r-smarttab/`).
2. **Do not rename** the folder (`0r-smarttab` must stay as expected for `ensure` and internal paths).
3. Confirm **`web/dist`** exists (see §4).

***

### 2. Database

**You must import the SQL manually (one time).** SmartTab will not create tables for you.

1. Use the **same MySQL database** your **oxmysql** connection string points to.
2. Import one of these (depending on your package):
   * **`tablet.sql`** (resource root), or
   * The **`sql/`** folder files (run in the order your package says).

#### How to run the SQL (pick one)

* **HeidiSQL / DBeaver / phpMyAdmin**:
  * Open your database → “Query” / “Import” → select `tablet.sql` (or the needed `sql/*.sql`) → **Run**.
* **mysql CLI** (example):

```bash
mysql -h 127.0.0.1 -u root -p your_database < tablet.sql
```

After SQL import: restart / `ensure 0r-smarttab`.

***

### 3. `server.cfg` load order

`ensure` lines run **in order**. Anything SmartTab relies on must start **before** `0r-smarttab`.

**Minimum idea:**

1. **0r\_lib**, **ox\_lib**, **oxmysql**, **xsound**, your **inventory**
2. **0r-dispatch** (and its own dependencies — see DISPATCH\_SETUP.md)
3. **0r-smarttab**

**Example** (resource names may differ on your host):

```cfg
ensure 0r_lib
ensure ox_lib
ensure oxmysql
ensure xsound
ensure ox_inventory

ensure 0r-dispatch

ensure 0r-smarttab
```

* Put **`ox_inventory`** (or your inventory) **before** `0r-smarttab` so hooks and `AddItem` paths work reliably.
* If SmartTab starts before **0r\_lib / oxmysql / 0r-dispatch**, expect errors and broken features.

***

### 4. Web UI (if needed)

If **`web/dist`** already contains built files (e.g. `index.html`, assets), **skip** this.

Otherwise, on a machine with [Node.js](https://nodejs.org):

```bash
cd path/to/0r-smarttab/web
npm install
npm run build
```

Upload the resource again so **`web/dist`** is present on the game server.

***

### 5. Quick configuration

| Where                    | What                                                                                                                                            |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| **`shared/config.lua`**  | `Config.TabletItem` — must match your inventory item **name** (default `tablet`). `Config.UseMetadata` — ownership via item serial when `true`. |
| **`server/config.json`** | Server-side mirror: `tabletItem`, `useMetadata`, upload URLs, mail, etc. Admin panel can edit and save this file.                               |

After changes, restart / **`ensure 0r-smarttab`**.

Details: CONFIGURATION.md.

***

### 6. Supported inventories & item setup

SmartTab detects **one** inventory at runtime (whichever resource is started among its supported list). You must **define the tablet item** in that inventory using the **same name** as `Config.TabletItem` / `tabletItem` in config (default **`tablet`**).

**Supported inventory resources:**

* **ox\_inventory**
* **qb-inventory**
* **ps-inventory**
* **lj-inventory**
* **core\_inventory**
* **codem-inventory**
* **qs-inventory**

Below are copy-paste examples for the two most common setups. For metadata/serials: METADATA\_SETUP.md.

***

#### ox\_inventory

{% tabs %}
{% tab title="ox\_inventory" %}
Add to your items file (e.g. `ox_inventory/data/items.lua` or your override).

```lua
['tablet'] = {
    label = 'Tablet',
    weight = 500,
    stack = false,  -- each unit can have its own metadata / serial
    close = true,
    description = 'SmartPad Tablet',
    -- use / client export is wired by 0r-smarttab + 0r_lib
},
```

**Image:** add `tablet.png` (or your icon name) under `ox_inventory/web/images` if your items use images.
{% endtab %}

{% tab title="qb-inventory" %}
**qb-inventory (QBCore-style shared items)**

Typical location: `qb-core/shared/items.lua` (or your inventory’s item table).

```lua
['tablet'] = {
    ['name'] = 'tablet',
    ['label'] = 'Tablet',
    ['weight'] = 500,
    ['type'] = 'item',
    ['image'] = 'tablet.png',
    ['unique'] = true,       -- recommended: one row per tablet for metadata
    ['useable'] = true,
    ['shouldClose'] = true,
    ['description'] = 'Advanced Tablet',
},
```

Place **`tablet.png`** in your inventory’s images folder as required by that resource.
{% endtab %}

{% tab title="Other Inventories" %}
**ps-inventory, lj-inventory, core\_inventory, codem-inventory, qs-inventory**

Typical location: `qb-core/shared/items.lua` (or your inventory’s item table).

```lua
['tablet'] = {
    ['name'] = 'tablet',
    ['label'] = 'Tablet',
    ['weight'] = 500,
    ['type'] = 'item',
    ['image'] = 'tablet.png',
    ['unique'] = true,       -- recommended: one row per tablet for metadata
    ['useable'] = true,
    ['shouldClose'] = true,
    ['description'] = 'Advanced Tablet',
},
```

{% endtab %}
{% endtabs %}

***

### Checklist

* [ ] **0r\_lib**, **ox\_lib**, **oxmysql**, **xsound**, **inventory**, **0r-dispatch** installed and starting without errors
* [ ] **Inventory** starts **before** `0r-smarttab` in `server.cfg`
* [ ] **SQL imported manually** into the oxmysql database
* [ ] Folder name **`0r-smarttab`** unchanged; **`web/dist`** present
* [ ] **`ensure 0r-dispatch`** before **`ensure 0r-smarttab`**
* [ ] Tablet **item** exists in your inventory config; **name** matches **`Config.TabletItem`** / **`tabletItem`**
* [ ] Optional: **prison** resource if you use Police jail features
* [ ] If UseMetadata **on**: read **METADATA\_SETUP.md** and use **GiveTablet** (or proper metadata) for shops

**Issues?** Configuration & FAQ

***

### Troubleshooting

| Symptom                    | Things to check                                                                                                                                                                       |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Console errors on start    | Load order: **0r\_lib**, **oxmysql**, **inventory**, **0r-dispatch** before SmartTab.                                                                                                 |
| Tablet item “does nothing” | Item **name** matches config; inventory resource running; **0r\_lib** usable-item bridge for your inventory.                                                                          |
| No serial / metadata (ox)  | **`useMetadata`: true** in `server/config.json` **and** `Config.UseMetadata` in `shared/config.lua`; SmartTab **after** ox\_inventory in `server.cfg`; item name matches hook filter. |

***

*Last updated for SmartTab install flow: dependencies, DB, cfg order, inventories, and optional prison note.*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.0resmon.org/0resmon/0r-resources/0r-tablet/installation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
