# Installation

## 📋 Prerequisites

Before installing InfinityUI, make sure you have:

* ✅ A FiveM server (txAdmin or standalone)
* ✅ **ox\_lib** resource installed
* ✅ Access to FiveM Keymaster
* ✅ Basic knowledge of Lua scripting

{% stepper %}
{% step %}

### 🛒 Step 1: Buy the product

* Go to <https://skshop.hibry.net>
* Log in with your FiveM account
* Go to the the [infinityUI product](https://skshop.hibry.net/package/7253291) and buy it !
  {% endstep %}

{% step %}

### 🔐 Step 2: Download from Keymaster

* Go to <https://keymaster.fivem.net>
* Log in with your account
* Navigate to "Granted Assets"
* Find **InfinityUI** in your purchased assets
* Download the resource
  {% endstep %}

{% step %}

### 📦 Step 3: Installation

#### Extract the Resource

1. Extract the downloaded ZIP file
2. You should see a folder named `infinityUI` (or similar)
3. Place this folder in your server's `resources` directory

Example structure:

```
your-server/
├── resources/
│   ├── [essential]/
│   ├── [gameplay]/
│   └── infinityUI/          ← Place it here
│       ├── fxmanifest.lua
|       ├── .fxap
│       ├── config.lua
│       └── client/
│           └── ui.lua
```

#### Add to server.cfg

Open your `server.cfg` file and add:

```cfg
# Dependencies
ensure ox_lib

# InfinityUI
ensure infinityUI
```

{% hint style="warning" %}
**Important:** Make sure `ox_lib` is started **before** `infinityUI`!
{% endhint %}
{% endstep %}

{% step %}

### ⚙️ Step 3: Configuration

InfinityUI requires a configuration file. To do it correctly, you have to:

#### Find the configuration file

1. Go into the resource infinityUI
2. Open config.lua
3. Check the [configuration section](https://infinityui.docs.hibry.net/configuration) for informations
4. Configure it
5. Save it
   {% endstep %}

{% step %}

### ✅ Step 4: Verify Installation

#### Test the Resource

1. Start your server
2. Check the server console for errors
3. Join your server
4. Open F8 console and type:

```lua
/infinityui_jump_to
```

If you see a dialog box, InfinityUI is working! ✅

#### Check for Errors

Look for these messages in your server console:

Good:

```
Started resource infinityUI
```

Bad:

```
Error loading script client/ui.lua
CONFIG FILE NOT FOUND
```

If you see errors, check:

* Is `config.lua` loaded before `ui.lua` in fxmanifest?
* Did you create the `InfinityUIConfig` table?
* Is `ox_lib` installed and started?
* If you can't find the error yourself, head to the support on the [Discord server](https://discord.gg/n6zXXG6BnT) !
  {% endstep %}

{% step %}

### 🔧 Step 5: Integration with Your Framework

#### ESX Example

```lua
-- In your config
InfinityUIConfig.CoreResource = "es_extended"

function InfinityUIConfig.GetPlayerMenuSide()
    local side = exports['es_extended']:getSharedObject().GetPlayerData().menuSide
    return side or "left"
end
```

#### QBCore Example

```lua
-- In your config
InfinityUIConfig.CoreResource = "qb-core"

function InfinityUIConfig.GetPlayerMenuSide()
    local PlayerData = exports['qb-core']:GetPlayerData()
    return PlayerData.metadata?.menuSide or "left"
end
```

#### Standalone (No Framework)

```lua
function InfinityUIConfig.GetPlayerMenuSide()
    -- Use a saved preference or default
    return "left" -- or "right"
end
```

{% endstep %}

{% step %}

### 🎨 Step 6: Create Your First Menu

Create a test script to verify everything works.

File: `test_infinityui.lua`

```lua
local TestMenu = InfinityUI.CreateMenu("Test Menu", "Testing InfinityUI")

Citizen.CreateThread(function()
    while true do
        Wait(0)
        
        if InfinityUI.IsVisible(TestMenu) then
            InfinityUI.Button("Test Button", "Click me!", {}, true, {
                onSelected = function()
                    print("InfinityUI works! ✅")
                end
            })
            
            InfinityUI.IsVisible(TestMenu)
        end
    end
end)

RegisterCommand("testmenu", function()
    InfinityUI.Visible(TestMenu, true)
end)
```

Add to your `fxmanifest.lua`:

```lua
client_scripts {
    '@infinityUI/config.lua',
    '@infinityUI/client/ui.lua',
    'test_infinityui.lua'
}
```

Then in game: `/testmenu`
{% endstep %}
{% endstepper %}

## 🐛 Troubleshooting

<details>

<summary>"CONFIG FILE NOT FOUND"</summary>

Problem: InfinityUI can't find your config.

Solution:

1. Make sure `@infinityUI/config.lua` is loaded BEFORE `@infinityUI/client/ui.lua`
2. Check that `InfinityUIConfig` table is created
3. Verify file path in `fxmanifest.lua`

</details>

<details>

<summary>"attempt to index a nil value (field 'MappingSettings')"</summary>

Problem: Config loaded but incomplete.

Solution: Add all required fields to your config:

```lua
InfinityUIConfig.MappingSettings = {
    Command = "infinityui_jump_to",
    Description = "Menu: Jump to a button"
}
```

</details>

<details>

<summary>Menu doesn't appear</summary>

Problem: Menu created but not visible.

Checklist:

* [ ] Did you call `InfinityUI.IsVisible(Menu)` in a thread?
* [ ] Did you use `InfinityUI.Visible(Menu, true)` to open it?
* [ ] Is your thread running? (check with print statements)
* [ ] Any errors in F8 console?

</details>

<details>

<summary>Sounds not working</summary>

Solution:

```lua
InfinityUIConfig.EnableSounds = true
```

</details>

## 📚 Next Steps

1. ✅ Read the [Configuration Guide](https://infinityui.docs.hibry.net/configuration)
2. ✅ Check the [API Reference](https://infinityui.docs.hibry.net/api-reference)
3. ✅ Join our [Discord](https://discord.gg/ZxHZrGvMmy) for help
