> For the complete documentation index, see [llms.txt](https://docs.menanak47.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.menanak47.com/multi-framework/ak47_hud/global-notifications-integration.md).

# Global Notifications Integration

If you want to route all default framework notifications (like job payouts, item usage, and system alerts) through the sleek `ak47_hud` notification system, you can easily set up a gateway inside your core framework files.

By making these simple changes, your framework will automatically check if the HUD is running. If it is, it uses the custom UI; if you ever stop the HUD, it safely falls back to the default notifications!

Choose your framework below and follow the steps.

### 🟢 ESX Integration

File to Edit: `es_extended/client/functions.lua`

1. Open the file and search for `function ESX.ShowNotification`.
2. Delete that entire function, along with `function ESX.ShowAdvancedNotification` right below it.
3. Replace them with the following code:

```lua
function ESX.ShowNotification(message, notifyType, length, title, position)
    if GetResourceState('ak47_hud') == 'started' then
        return exports['ak47_hud']:Notify(message, notifyType, length, title)
    end
    return IsResourceFound('esx_notify') and exports['esx_notify']:Notify(notifyType or "info", length or 5000, message, title, position)
end

function ESX.ShowAdvancedNotification(sender, subject, msg, textureDict, iconType, flash, saveToBrief, hudColorIndex)
    if GetResourceState('ak47_hud') == 'started' then
        return exports['ak47_hud']:Notify(msg, 'info', 7000, sender)
    end
    
    AddTextEntry("esxAdvancedNotification", msg)
    BeginTextCommandThefeedPost("esxAdvancedNotification")
    if hudColorIndex then
        ThefeedSetNextPostBackgroundColor(hudColorIndex)
    end
    EndTextCommandThefeedPostMessagetext(textureDict, textureDict, false, iconType, sender, subject)
    EndTextCommandThefeedPostTicker(flash, saveToBrief == nil or saveToBrief)
end
```

### 🔵 QBCore Integration

File to Edit: `qb-core/client/functions.lua`

1. Open the file and search for `function QBCore.Functions.Notify`.
2. Highlight the entire function and replace it with the following code:

```lua
function QBCore.Functions.Notify(text, texttype, length, icon)
    if GetResourceState('ak47_hud') == 'started' then
        exports['ak47_hud']:Notify(text, texttype, length, icon)
        return
    end
    
    local message = {
        action = 'notify',
        type = texttype or 'primary',
        length = length or 5000,
    }

    if type(text) == 'table' then
        message.text = text.text or 'Placeholder'
        message.caption = text.caption or 'Placeholder'
    else
        message.text = text
    end

    if icon then
        message.icon = icon
    end

    SendNUIMessage(message)
end
```

### 🟣 ox\_lib Integration

File to Edit: `ox_lib/resource/interface/client/notify.lua` *(or search your ox\_lib files for `function lib.notify`)*

1. Open the file and locate `function lib.notify(data)`.
2. Highlight the entire function block and replace it with the following code:

```lua
function lib.notify(data)
    if GetResourceState('ak47_hud') == 'started' then
        exports['ak47_hud']:Notify(data.description, data.type, data.duration, data.title)
        return
    end

    local sound = settings.notification_audio and data.sound
    local payload = table.clone(data)
    payload.sound = nil
    payload.position = payload.position or settings.notification_position

    SendNUIMessage({
        action = 'notify',
        data = payload
    })

    if not sound then return end

    if sound.bank then lib.requestAudioBank(sound.bank) end

    local soundId = GetSoundId()
    PlaySoundFrontend(soundId, sound.name, sound.set, true)
    ReleaseSoundId(soundId)

    if sound.bank then ReleaseNamedScriptAudioBank(sound.bank) end
end
```

> Important Note: Whenever you update `es_extended`, `qb-core`, or `ox_lib` to a new version from their respective GitHub repositories, you may need to re-apply these changes, as updating core files will overwrite your modifications.
