> For the complete documentation index, see [llms.txt](https://s1h.gitbook.io/info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://s1h.gitbook.io/info/resources/s1h_uipack/editable-files/exports/radial-menu.md).

# Radial Menu

***

### OpenRadialMenu

Opens the radial menu with a **custom** list of items, bypassing the default config menus entirely.

**You can use it to open a completely custom radial menu from any script — during a job action, inside a vehicle, at a specific location, or as part of a mission.**

```lua
exports["s1h_uipack"]:OpenRadialMenu(items)
```

**Parameters :**

| Name  | Type  | Description                                         |
| ----- | ----- | --------------------------------------------------- |
| items | table | Array of radial item tables (see item fields below) |

**Radial item fields :**

| Name           | Type    | Description                                                                                                                 |
| -------------- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
| id             | string  | Unique identifier for this item (recommended)                                                                               |
| label          | string  | Text label shown on the radial slice                                                                                        |
| icon           | string  | FontAwesome class (e.g. `"fas fa-car"`)                                                                                     |
| type           | string  | `"client"` — triggers a client event (default). `"server"` — triggers a server event. `"command"` — executes a chat command |
| event          | string  | The event name or command to fire when this slice is clicked                                                                |
| serverEvent    | boolean | Alternative to `type = "server"`. If `true`, triggers a server event                                                        |
| args           | table   | Extra data passed to the triggered event                                                                                    |
| shouldClose    | boolean | If `false`, the menu stays open after the click. Default: `true`                                                            |
| disabled       | boolean | Greys out the slice — it is visible but cannot be clicked                                                                   |
| menu           | string  | Opens a named sub-menu defined in `Config.RadialMenu.SubMenus`                                                              |
| items          | table   | Inline sub-menu — opens a nested radial with these items on click                                                           |
| allowlist.jobs | table   | Restricts this item to specific jobs. Format: `{ jobName = minGrade }`                                                      |

***

**Example — standard client / server / command items :**

```lua
exports["s1h_uipack"]:OpenRadialMenu({
    -- Client event
    {
        id    = "phone",
        label = "Phone",
        icon  = "fas fa-mobile-alt",
        type  = "client",
        event = "phone:open"
    },
    -- Server event
    {
        id    = "call_taxi",
        label = "Call Taxi",
        icon  = "fas fa-taxi",
        type  = "server",
        event = "taxi:server:callTaxi"
    },
    -- Chat command (writes /inventory in chat)
    {
        id    = "inventory",
        label = "Inventory",
        icon  = "fas fa-backpack",
        type  = "command",
        event = "inventory"
    }
})
```

***

**Example — passing args to an event :**

```lua
exports["s1h_uipack"]:OpenRadialMenu({
    {
        id    = "extra1",
        label = "Toggle Extra 1",
        icon  = "fas fa-box-open",
        type  = "client",
        event = "vehicle:client:setExtra",
        args  = { extra = 1 }
    },
    {
        id    = "extra2",
        label = "Toggle Extra 2",
        icon  = "fas fa-box-open",
        type  = "client",
        event = "vehicle:client:setExtra",
        args  = { extra = 2 }
    }
})
```

***

**Example — keep menu open after click (shouldClose = false) :**

```lua
-- Useful for toggles — player can tap multiple times without reopening the menu
exports["s1h_uipack"]:OpenRadialMenu({
    {
        id          = "lights",
        label       = "Toggle Lights",
        icon        = "fas fa-lightbulb",
        type        = "client",
        event       = "vehicle:client:toggleLights",
        shouldClose = false
    },
    {
        id          = "engine",
        label       = "Toggle Engine",
        icon        = "fas fa-key",
        type        = "client",
        event       = "vehicle:client:toggleEngine",
        shouldClose = false
    }
})
```

***

**Example — inline sub-menu (items table) :**

```lua
-- Clicking "Vehicle Actions" opens a nested radial with sub-items
exports["s1h_uipack"]:OpenRadialMenu({
    {
        id    = "vehicle_actions",
        label = "Vehicle",
        icon  = "fas fa-car",
        items = {
            { id = "lock",   label = "Lock / Unlock", icon = "fas fa-lock",      type = "client", event = "vehicle:client:lock" },
            { id = "engine", label = "Engine",        icon = "fas fa-power-off", type = "client", event = "vehicle:client:engine" },
            { id = "windows",label = "Windows",       icon = "fas fa-wind",      type = "client", event = "vehicle:client:windows", shouldClose = false }
        }
    },
    {
        id    = "phone",
        label = "Phone",
        icon  = "fas fa-mobile-alt",
        type  = "client",
        event = "phone:open"
    }
})
```

***

**Example — named sub-menu (menu = string, defined in Config.RadialMenu.SubMenus) :**

```lua
-- The 'personal_menu' string references a sub-menu in shared_radialmenu.lua
exports["s1h_uipack"]:OpenRadialMenu({
    {
        id    = "personal",
        label = "Personal",
        icon  = "fas fa-user",
        menu  = "personal_menu"   -- must exist in Config.RadialMenu.SubMenus
    }
})
```

***

**Example — job restricted items (allowlist) :**

```lua
exports["s1h_uipack"]:OpenRadialMenu({
    -- Only visible to police officers (any grade)
    {
        id        = "dispatch",
        label     = "Dispatch",
        icon      = "fas fa-radio",
        type      = "client",
        event     = "police:client:openDispatch",
        allowlist = { jobs = { police = 0 } }
    },
    -- Only visible to police sergeants (grade 3+)
    {
        id        = "suspect_file",
        label     = "Suspect File",
        icon      = "fas fa-file-alt",
        type      = "client",
        event     = "police:client:openSuspectFile",
        allowlist = { jobs = { police = 3 } }
    },
    -- Multiple jobs allowed
    {
        id        = "ems_radio",
        label     = "EMS Radio",
        icon      = "fas fa-heartbeat",
        type      = "client",
        event     = "ems:client:openRadio",
        allowlist = { jobs = { ambulance = 0, doctor = 0 } }
    },
    -- No restriction — visible to everyone
    {
        id    = "phone",
        label = "Phone",
        icon  = "fas fa-mobile-alt",
        type  = "client",
        event = "phone:open"
    }
})
```

***

**Example — disabled item :**

```lua
exports["s1h_uipack"]:OpenRadialMenu({
    {
        id       = "feature",
        label    = "Coming Soon",
        icon     = "fas fa-lock",
        disabled = true   -- greyed out, cannot be clicked
    },
    {
        id    = "phone",
        label = "Phone",
        icon  = "fas fa-mobile-alt",
        type  = "client",
        event = "phone:open"
    }
})
```

***

### CloseRadialMenu

Programmatically closes the radial menu.

**You can use it to force-close the radial menu when a cutscene starts, a minigame opens, the player is arrested, or any other situation where the menu should not remain open.**

```lua
exports["s1h_uipack"]:CloseRadialMenu()
```

**Example :**

```lua
-- Force close the menu when a cutscene begins
AddEventHandler("myScript:client:cutsceneStart", function()
    exports["s1h_uipack"]:CloseRadialMenu()
end)

-- Force close when the player is handcuffed
RegisterNetEvent("police:client:handcuff", function()
    exports["s1h_uipack"]:CloseRadialMenu()
end)
```

***

### Config-based Setup (shared/shared\_radialmenu.lua)

The permanent radial menu — what opens when the player presses the keybind — is configured entirely in `shared/shared_radialmenu.lua`. You do not need exports for this.

**Full Config structure :**

```lua
Config.RadialMenu = {
    Active  = true,           -- Enable or disable the entire radial menu module
    Command = "radialmenu",   -- The command name (also registered as a keybind)
    Keybind = "F3",           -- Default keybind key

    CenterIcon = "fas fa-times",   -- Icon shown in the center close button
    BackIcon   = "fas fa-undo",    -- Icon shown in the back button (inside sub-menus)

    -- ── DEFAULT MAIN MENU ────────────────────────────────────────────────────
    -- These items are always shown when the player opens the radial menu on foot.
    DefaultMenu = {

        -- Named sub-menu reference
        { id = "personal", label = "Personal", icon = "fas fa-user", menu = "personal_menu" },
        { id = "vehicle",  label = "Vehicle",  icon = "fas fa-car",  menu = "vehicle_menu" },

        -- Inline sub-menu (police only, grade 2+)
        {
            id        = "police_actions",
            label     = "Police Actions",
            icon      = "fas fa-shield-alt",
            allowlist = { jobs = { police = 2 } },
            items = {
                { id = "handcuff", label = "Handcuff",  icon = "fas fa-link",    type = "client", event = "police:client:handcuff",  shouldClose = true },
                { id = "check_id", label = "Check ID",  icon = "fas fa-id-card", type = "client", event = "police:client:checkId",   shouldClose = true,
                    allowlist = { jobs = { police = 3 } }   -- nested restriction: grade 3+ for this specific item
                },
                { id = "search",   label = "Search",    icon = "fas fa-search",  type = "server", event = "police:server:searchPlayer", shouldClose = true }
            }
        },

        -- Chat command
        { id = "inventory", label = "Inventory", icon = "fas fa-backpack", type = "command", event = "inventory", shouldClose = true },

        -- Standard client event
        { id = "phone", label = "Phone", icon = "fas fa-mobile-alt", type = "client", event = "phone:open", shouldClose = true }
    },

    -- ── VEHICLE MENU ─────────────────────────────────────────────────────────
    -- These items are ADDED to DefaultMenu when the player is inside a vehicle.
    VehicleMenu = {
        {
            id    = "vehicle_extras",
            label = "Vehicle Extras",
            icon  = "fas fa-plus",
            items = {
                { id = "extra1", label = "Extra 1", icon = "fas fa-box-open", type = "client", event = "vehicle:client:setExtra", args = { extra = 1 }, shouldClose = false },
                { id = "extra2", label = "Extra 2", icon = "fas fa-box-open", type = "client", event = "vehicle:client:setExtra", args = { extra = 2 }, shouldClose = false }
            }
        }
    },

    -- ── DEAD MENU ─────────────────────────────────────────────────────────────
    -- These items REPLACE DefaultMenu when the player is dead.
    DeadMenu = {
        { id = "distress", label = "Distress Signal", icon = "fas fa-heart-pulse", type = "client", event = "hospital:client:sendDistress", shouldClose = true }
    },

    -- ── NAMED SUB-MENUS ───────────────────────────────────────────────────────
    -- Referenced by items that use `menu = "sub_menu_name"`.
    SubMenus = {
        ["personal_menu"] = {
            { id = "id_card", label = "Show ID",  icon = "fas fa-id-card", type = "client", event = "myScript:client:showID",   shouldClose = true },
            { id = "wallet",  label = "Wallet",   icon = "fas fa-wallet",  type = "client", event = "myScript:client:checkWallet", shouldClose = true }
        },
        ["vehicle_menu"] = {
            { id = "engine",  label = "Engine",         icon = "fas fa-key",       type = "client", event = "vehicle:client:toggleEngine", shouldClose = true },
            { id = "doors",   label = "Lock / Unlock",  icon = "fas fa-door-open", type = "client", event = "vehicle:client:toggleLock",   shouldClose = true },
            { id = "repair",  label = "Repair Vehicle", icon = "fas fa-wrench",    type = "client", event = "vehicle:client:repairVehicle",shouldClose = true }
        }
    }
}
```
