> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fzd-scripts.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating actions

> Register actions, nested menus and outcomes from another resource.

Actions are sequential Lua arrays. Give every action and child a unique, namespaced ID.

```lua theme={null}
{
    id = 'my_resource:repair',
    label = 'Repair Vehicle',
    icon = 'wrench',
    clientEvent = 'my_resource:repairVehicle',
    payload = { source = 'wheel' }
}
```

## Register an action on the normal wheel

```lua theme={null}
local function registerWheelAction()
    if GetResourceState('fzd_actionwheel') ~= 'started' then return end

    exports.fzd_actionwheel:removeAction('my_emotes:open')

    local ok, reason = exports.fzd_actionwheel:registerAction({
        id = 'my_emotes:open',
        label = 'Emotes',
        icon = 'hand',
        clientEvent = 'my_emotes:openFromWheel'
    })

    if not ok then
        print(('[my_emotes] Registration failed: %s'):format(tostring(reason)))
    end
end

AddEventHandler('onClientResourceStart', function(resourceName)
    if resourceName == GetCurrentResourceName()
        or resourceName == 'fzd_actionwheel' then
        registerWheelAction()
    end
end)
```

External top-level registrations are removed automatically if their owner resource stops. Registrations live in client memory, so integrations should register again after FzD Action Wheel restarts.

## Nested menus

```lua theme={null}
exports.fzd_actionwheel:registerAction({
    id = 'my_vehicle:menu',
    label = 'Vehicle',
    icon = 'car',
    inVehicle = true,
    children = {
        {
            id = 'my_vehicle:engine',
            label = 'Engine',
            icon = 'power-off',
            clientEvent = 'my_vehicle:toggleEngine'
        },
        {
            id = 'my_vehicle:doors',
            label = 'Doors',
            icon = 'door-open',
            children = {
                {
                    id = 'my_vehicle:boot',
                    label = 'Boot',
                    icon = 'suitcase',
                    clientEvent = 'my_vehicle:toggleBoot'
                }
            }
        }
    }
})
```

Menus support up to five levels including the root.

## Action outcome priority

If multiple outcomes are supplied, FzD uses this order:

1. `clientEvent`
2. `serverEvent`
3. `command`
4. Generic `fzd_actionwheel:selected` event when no explicit outcome exists

Non-empty `children` take precedence over all outcomes.
