# Installation

## Step 1 — Download

After your purchase on [Tebex](https://hzscripts.com/shop), download the script from your **FiveM Keymaster**:

1. Log in to [keymaster.fivem.net](https://keymaster.fivem.net/)
2. Go to **Granted Assets**
3. Download `HZ-Television`

{% hint style="warning" %}
**Important:** Use the same FiveM account that is linked to your Tebex license. The script is escrow protected and requires a valid license.
{% endhint %}

## Step 2 — Dependencies

Download and install the required dependencies:

### Required

1. **HZ-Bridge** (free)
   * Download from [Hz-Scripts shop](https://hzscripts.com/shop) — free asset
   * See [HZ-Bridge Installation](https://hz-script.gitbook.io/hz-script-docs/free-tools/hz-bridge/installation) for setup
   * Must start **before** HZ-Television in `server.cfg`
2. **generic\_texture\_renderer\_gfx**
   * Included in the HZ-Television download archive
3. **A menu system** — at least one of:
   * **ox\_lib** (recommended): [overextended/ox\_lib](https://github.com/overextended/ox_lib)
   * **qb-menu + qb-input**: Provided with QBCore

### Optional

* **oxmysql**: For placed TV persistence
* **ox\_target / qb-target**: For target interaction (otherwise TextUI mode)

{% hint style="info" %}
**HZ-Bridge** handles all framework, inventory, target, and notification detection automatically. You no longer need to configure these per-script — they are configured once in HZ-Bridge's `config.lua`. See [HZ-Bridge Configuration](https://hz-script.gitbook.io/hz-script-docs/free-tools/hz-bridge/configuration).
{% endhint %}

## Step 3 — Files

1. Extract the `HZ-Television.zip` archive
2. Place the `HZ-Television` and `generic_texture_renderer_gfx` folder in your `resources/` directory

```
server/
├── resources/
│   ├── generic_texture_renderer_gfx/
│   ├── ox_lib/
│   ├── [hz-scripts]/
│   │   ├── HZ-Television/
│   │   │   ├── client/
│   │   │   ├── server/
│   │   │   ├── html/
│   │   │   ├── bridge/
│   │   │   ├── config.lua
│   │   │   ├── fxmanifest.lua
│   │   │   └── ...
```

## Step 4 — Inventory Items

Add TV items to your inventory system. Pre-configured files are provided in `HZ-Television/items/`:

### For ox\_inventory

Open `ox_inventory/data/items.lua` and add:

```lua
['tv_flat_01'] = {
    label = 'Flat Screen TV',
    weight = 5000,
    stack = false,
    close = true,
    description = 'Portable television with HD flat screen',
    client = {
        export = 'HZ-Television.UseTV'
    }
},

['tv_monitor_01'] = {
    label = 'PC Monitor',
    weight = 3000,
    stack = false,
    close = true,
    description = 'Portable computer monitor',
    client = {
        export = 'HZ-Television.UseTV'
    }
},
```

### For qb-inventory

Open `qb-core/shared/items.lua` and add:

```lua
['tv_flat_01'] = {
    name = 'tv_flat_01',
    label = 'Flat Screen TV',
    weight = 5000,
    type = 'item',
    image = 'tv_flat_01.png',
    unique = false,
    useable = true,
    shouldClose = true,
    description = 'Portable television with HD flat screen'
},
```

{% hint style="info" %}
Copy the complete content from the corresponding file in `items/` according to your inventory.
{% endhint %}

## Step 5 — Database (optional)

{% hint style="info" %}
This step is **optional**. The database allows placed TVs to persist between server restarts.
{% endhint %}

If you want persistence, enable it in `config.lua`:

```lua
Config.Placer = {
    Persistence = true,  -- Enable database saving
}
```

The `hz_television_placed` table will be created automatically on first startup.

Or import manually:

```sql
CREATE TABLE IF NOT EXISTS `hz_television_placed` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `owner` varchar(50) NOT NULL,
  `model` varchar(50) NOT NULL,
  `coords` text NOT NULL,
  `url` text DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
```

## Step 6 — server.cfg

Add the resources to your `server.cfg` in this order:

```cfg
# Dependencies
ensure generic_texture_renderer_gfx
ensure ox_lib  # or qb-menu if QBCore

# Framework (if applicable)
ensure es_extended
# ensure qb-core

# HZ-Bridge (required — free asset, before all Hz-Scripts)
ensure HZ-Bridge

# Hz-Scripts
ensure HZ-Television
```

{% hint style="danger" %}
**Startup order is important!** `generic_texture_renderer_gfx`, your menu system, and `HZ-Bridge` must start **before** HZ-Television.
{% endhint %}

## Step 7 — Configuration

Open `config.lua` and adapt the settings to your server. See the [Configuration](https://hz-script.gitbook.io/hz-script-docs/scripts/hz-television/configuration) page for details on each option.

**Essential settings to check:**

* `Config.Locale`: Language (`'en'` or `'fr'`)
* `Config.Permissions`: Who can use admin commands

{% hint style="info" %}
Framework, target, menu, and notification settings are now managed centrally by **HZ-Bridge**. See [HZ-Bridge Configuration](https://hz-script.gitbook.io/hz-script-docs/free-tools/hz-bridge/configuration).
{% endhint %}

## Step 8 — Verification

1. Start your server
2. Connect in-game
3. Approach a TV (ex: `prop_tv_flat_01`)
4. Use your target system or press `E`
5. Select **Power On** then **Smart TV**
6. Check the server console: `[HZ-Television] v2.0.0 loaded successfully`

{% hint style="success" %}
**Done!** If the menu opens and you can paste a YouTube URL, the script is working. Move on to [Configuration](https://hz-script.gitbook.io/hz-script-docs/scripts/hz-television/configuration) to customize.
{% endhint %}

***

## Quick Troubleshooting

<details>

<summary>The script doesn't start</summary>

Check that:

* The folder is correctly named `HZ-Television` (case sensitive)
* `HZ-Bridge` is installed and started **before** HZ-Television
* `generic_texture_renderer_gfx` is installed and started before
* Your FiveM license is valid on the Keymaster
* A menu system (ox\_lib or qb-menu) starts **before** HZ-Bridge

</details>

<details>

<summary>Error "Framework not detected"</summary>

Framework detection is handled by **HZ-Bridge**. Make sure that:

* `es_extended` or `qb-core` is properly `ensure`d before `HZ-Bridge`
* `HZ-Bridge` is `ensure`d before `HZ-Television`
* Check the HZ-Bridge console line to verify detection is correct
* If needed, force a framework in HZ-Bridge's `config.lua`: `HZBridge.Framework = 'esx'`

</details>

<details>

<summary>Screen stays black / no display</summary>

* Check that `generic_texture_renderer_gfx` is properly installed and started
* Use `/tvcfg` near a TV to calibrate the screen position
* Test with a simple YouTube video (not a live stream to start)
* Check the F8 console for JavaScript errors

</details>

<details>

<summary>No sound or global sound</summary>

* Increase `Config.Display.MaxSoundDistance` in config.lua
* Check that the TV is turned on (Power On)
* Get closer to the TV (volume decreases with distance)

</details>

<details>

<summary>TV items don't appear in inventory</summary>

* Check that you properly added the items to your inventory system
* Restart the server completely after adding items
* For ox\_inventory, check the path `ox_inventory/data/items.lua`
* For QBCore, check `qb-core/shared/items.lua`

</details>
