# Installation

### 1) Requirements

#### Required

* `ox_lib`
* `oxmysql`

#### Target (pick one)

* `ox_target` **or** `qb-target` **or** `qtarget`\
  This resource uses targets to interact with the garage/impound NPCs. If no target provider is running, players will not have an in-game interaction by default.

### 2) Database

Import `db.sql` (included with the resource).\
It adds these columns:

* `garage_state` *(INT, default 1)*
  * `1` = stored in garage
  * `0` = OUT (spawned)
  * `2` = impounded
* `garage_id` *(VARCHAR(64), nullable)*
* `garage_updated` *(TIMESTAMP auto update)*
* sql for documentation

  ```sql
  CREATE TABLE IF NOT EXISTS `3m_garage_vehicle_docs` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `plate` varchar(12) NOT NULL,
    `vin` char(17) DEFAULT NULL,
    `holder_first` varchar(32) DEFAULT NULL,
    `holder_last` varchar(32) DEFAULT NULL,
    `reg_from` int(10) unsigned DEFAULT 0,
    `reg_to` int(10) unsigned DEFAULT 0,
    `ins_from` int(10) unsigned DEFAULT 0,
    `ins_to` int(10) unsigned DEFAULT 0,
    `doc_token` varchar(48) DEFAULT NULL,
    `printed_at` int(10) unsigned DEFAULT 0,
    `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
    `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
    PRIMARY KEY (`id`),
    KEY `plate` (`plate`)
  ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
  ```

### 3) Items (Docs feature)

If you enable the Docs feature and want printable papers:

* Add an item (default: `vehicle_papers`) to your inventory
* Make sure it supports metadata (recommended: `ox_inventory`)

Examples are in **items.md**.

### 4) Configure

Open `shared/config.lua` and set:

* `Config.Framework` (`auto`, `esx`, `qb`)
* `Config.Target` (`auto`, `ox`, `qb-target`, `qtarget`, `none`)
* `Config.Notification.provider`
* `Config.Keys.provider`
* `Config.Fuel.provider`
* Garages / Impounds lists
* (Optional) Docs settings
*
* ## Add Item to inventory

### ox\_inventory (recommended)

Add an item (default: `vehicle_papers`) and let it trigger the client event:

```lua
['vehicle_papers'] = {
  label = 'Vehicle Papers',
  weight = 1,
  stack = true,
  close = true,
  description = 'Printed vehicle documentation.',
  client = {
    event = '3m_garage:cl:useVehiclePapers'
  }
},
```

#### Metadata

When printing, the script gives this metadata:

* `plate`
* `vin`
* `doc_token`
* `printed_at`

### 5) Start order

Typical `server.cfg` order:

* ensure `oxmysql`
* ensure `ox_lib`
* ensure your target (`ox_target` / `qb-target` / `qtarget`)
* ensure your inventory (recommended `ox_inventory`)
* ensure `3M_Garage`

### 6) Verify in-game

1. Go to a configured garage NPC
2. Open the UI
3. Spawn a stored vehicle
4. Store it back
5. Test impound takeout and fees
6. (Optional) Test Docs purchase + print + show papers
