> For the complete documentation index, see [llms.txt](https://mole-resource.gitbook.io/mole-resource-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mole-resource.gitbook.io/mole-resource-docs/scripts/hanoi-tower/installation.md).

# Installation

## 1. Download Resource

Download **mr\_hanoitower** and place it in your server's `resources` folder.

The resource includes the custom props (`mr_hanoi_base`, `mr_hanoi_disk1`–`mr_hanoi_disk7`) — no separate prop pack is needed.

***

## 2. Install Required Dependencies

This script needs the following resources to work properly. Click the link, download and upload to your server just like other resources.

<table data-full-width="false"><thead><tr><th width="251">Resource</th><th data-type="content-ref">Download Link</th></tr></thead><tbody><tr><td><strong>oxmysql</strong></td><td><a href="https://github.com/overextended/oxmysql">https://github.com/overextended/oxmysql</a></td></tr><tr><td><strong>ox_inventory (optional)*</strong></td><td><a href="https://github.com/overextended/ox_inventory">https://github.com/overextended/ox_inventory</a></td></tr><tr><td><strong>ox_lib (optional)</strong></td><td><a href="https://github.com/overextended/ox_lib">https://github.com/overextended/ox_lib</a></td></tr><tr><td><strong>ox_target (optional)**</strong></td><td><a href="https://github.com/CommunityOx/ox_target">https://github.com/CommunityOx/ox_target</a></td></tr><tr><td><strong>sleepless_interact (optional)**</strong></td><td><a href="https://github.com/Sleepless-Development/sleepless_interact">https://github.com/Sleepless-Development/sleepless_interact</a></td></tr></tbody></table>

{% hint style="info" %}
\* You need **one** inventory system: ox\_inventory, QBCore inventory, or classic ESX inventory. Set your choice in `config.lua` → `Config.Framework` (see step 5).

\*\* Optional interaction system — set `Config.Target` to `"ox_target"` or `"sleepless_interact"` to use it instead of the built-in **E**/**G** proximity prompts.
{% endhint %}

***

## 3. Import Database Table

This is a very important step — without it, the script will not work properly. **Import the `hanoi_boards.sql` file included in the resource into your database** — or paste the SQL below manually.

<details>

<summary>Database (all frameworks)</summary>

```sql
CREATE TABLE IF NOT EXISTS `hanoi_boards` (
  `id`         INT(11) NOT NULL AUTO_INCREMENT,
  `x`          FLOAT NOT NULL,
  `y`          FLOAT NOT NULL,
  `z`          FLOAT NOT NULL,
  `rotation`   FLOAT NOT NULL DEFAULT 0,
  `disk_count` INT(11) NOT NULL DEFAULT 7,
  `pegs`       TEXT NOT NULL,
  `move_count` INT(11) DEFAULT 0,
  `started_at` BIGINT DEFAULT NULL,
  `instance`   VARCHAR(64) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
```

</details>

{% hint style="warning" %}

## Not sure how to do it?

Open **HeidiSQL / phpMyAdmin**, select your server's database, open the SQL query tab, paste the code above and execute it. The table `hanoi_boards` will appear in the table list.
{% endhint %}

***

## 4. Add Required Item

The script uses one inventory item (default name: `hanoitower`). Depending on what inventory you are using, select the appropriate section and add the item to either your item file or database.

<details>

<summary>Item for ox_inventory</summary>

Add to `ox_inventory/data/items.lua`:

```lua
['hanoitower'] = {
    label = 'Tower of Hanoi',
    weight = 2000,
    stack = false,
    close = true,
    client = {
			event = "mr_hanoitower:PlaceBoard"
		}
},
```

</details>

<details>

<summary>Item for qb-inventory / qs-inventory</summary>

Add to `qb-core/shared/items.lua`:

```lua
['hanoitower'] = {
    ["name"] = 'hanoitower',
    ["label"] = "Tower of Hanoi",
    ["description"] = "A classic puzzle board",
    ["weight"] = 2000,
    ["type"] = "item",
    ["image"] = "hanoitower.png",
    ["unique"] = true,
    ["useable"] = true,
    ["shouldClose"] = true,
    ["combinable"] = nil,
},
```

The use action is registered automatically by the script (`Config.Framework = "qb"`).

</details>

<details>

<summary>Item for classic ESX inventory</summary>

```sql
INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES
    ("hanoitower", "Tower of Hanoi", 2000, 0, 1);
```

The use action is registered automatically by the script (`Config.Framework = "esx"`).

</details>

{% hint style="info" %}
Using a different item name? Change `Config.ItemName` in `config.lua` and use your name everywhere above.
{% endhint %}

***

## 5. Set Your Framework

Open `config.lua` and set the inventory system your server uses:

```lua
Config.Framework = "ox"   -- "ox" | "qb" | "esx"
Config.ItemName  = "hanoitower"
```

***

## 6. Start Resource

To start the resource in your `server.cfg`, ensure that it begins **after** oxmysql, your framework, and your inventory. For instance:

```python
# Database
start oxmysql

start [core]             # Your framework (es_extended / qb-core)

start ox_inventory       # Your inventory (if used)

# mr Resources
start mr_hanoitower
```

Ensure there are no syntax errors or incorrect paths in your `server.cfg`.

***

## 7. First Test

1. Restart the server (or `ensure mr_hanoitower`)
2. Give yourself the item — e.g. `/hanoiitem` (debug command) or via your admin menu
3. Use the item from your inventory → a translucent board preview follows your cursor
4. **Scroll** to rotate, **Left-click** to place, **ESC** to cancel
5. Walk up to the board and press **E** to play

{% hint style="info" %}
After joining the server, boards appear **`Config.SyncDelay` ms later** (default 20 s). This guarantees the game world is fully loaded before objects are created — it is expected behaviour, not a bug.
{% endhint %}
