# Swap in framework

***

Here are the modified functions to your framework to make notifications and textui automatically adjust as vms\_notifyV2.

<details>

<summary>ESX</summary>

### Notification

1. Navigate to `es_extended/client/functions.lua`
2. Find function `ESX.ShowNotification`
3. Replace the function with the one below

```lua
function ESX.ShowNotification(message, notifyType, length)
    local type = "info" -- Default preset if there is no notifyType
    
    if notifyType == "success" then
        type = "success" -- Default preset for "success" type notification
    elseif notifyType == "error" then
        type = "error" -- Default preset for "error" type notification
    end
    
    if length ~= nil and not tonumber(length) then
        length = 5000 -- If the time is not given correctly or if it is not as a number
    end    

    return exports['vms_notifyv2']:Notification({
        description = message,
        time = length,
        preset = type
    })
end
```

4. Find function `ESX.ShowAdvancedNotification`
5. Replace the function with the one below

```lua
function ESX.ShowAdvancedNotification(sender, subject, msg, textureDict, iconType, flash, saveToBrief, hudColorIndex)
    if subject and subject ~= "" then
        exports['vms_notifyv2']:Notification({
            title = sender,
            description = subject .. '~n~' .. msg,
            time = 6500,
            preset = 'info'
        })
    else
        exports['vms_notifyv2']:Notification({
            title = sender,
            description = msg,
            time = 6500,
            preset = 'info'
        })
    end
end
```

### TextUI

1. Navigate to `es_extended/client/functions.lua`
2. Find function `ESX.TextUI` and `ESX.HideUI`
3. Replace the function with the one below

```lua
function ESX.TextUI(message)
    exports['vms_notifyv2']:ShowTextUI(message)
end

function ESX.HideUI()
    exports['vms_notifyv2']:HideTextUI(message)
end
```

</details>

<details>

<summary>QB-Core</summary>

### Notification

1. Navigate to `qb-core/client/functions.lua`
2. Find function `QBCore.Functions.Notify`
3. Replace the function with the one below

```lua
function QBCore.Functions.Notify(text, texttype, length, icon)
    local message = {
        action = 'notify',
        type = texttype or 'info',
        length = length or 5000,
    }

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

    local description = ""
    if message.caption then
        description = message.text .. '~s~' .. message.caption
    else
        description = message.text
    end

    if message.type == "primary" then
        message.type = "info"
    end

    if icon then
        message.icon = icon
    end

    exports['vms_notifyv2']:Notification({
        description = description,
        time = length,
        icon = message.icon,
        preset = message.type
    })
end
```

### TextUI

1. Navigate to `qb-core/client/drawtext.lua`
2. Replace the entire file with the following code

```lua
local function hideText()
    exports['vms_notifyv2']:HideTextUI()
end

local function drawText(text, position)
    exports['vms_notifyv2']:ShowTextUI(text)
end

local function changeText(text, position)
    exports['vms_notifyv2']:UpdateTextUI(text)
end

local function keyPressed()
    exports['vms_notifyv2']:HideTextUI()
end

RegisterNetEvent('qb-core:client:DrawText', function(text, position)
    drawText(text)
end)

RegisterNetEvent('qb-core:client:ChangeText', function(text, position)
    changeText(text)
end)

RegisterNetEvent('qb-core:client:HideText', function()
    hideText()
end)

RegisterNetEvent('qb-core:client:KeyPressed', function()
    keyPressed()
end)

exports('DrawText', drawText)
exports('ChangeText', changeText)
exports('HideText', hideText)
exports('KeyPressed', keyPressed)
```

</details>

<details>

<summary>QBOX-Core</summary>

### Notification

1. Navigate to `qbx_core/client/functions.lua`
2. Find function `Notify`
3. Replace the function with the one below

```lua
function Notify(text, notifyType, duration, subTitle, notifyPosition, notifyStyle, notifyIcon, notifyIconColor)
    local title, description
    
    if type(text) == 'table' then
        title = text.text
        description = text.caption or nil
    elseif subTitle then
        title = text
        description = subTitle
    else
        description = text
    end
    
    if not notifyType or notifyType and notifyType == "primary" then
        notifyType = "info"
    end
        
    exports['vms_notifyv2']:Notification({
        title = title,
        description = description,
        time = duration,
        icon = notifyIcon,
        preset = notifyType
    })
end
```

### TextUI

1. Navigate to `qbx_core/bridge/qb/client/drawtext.lua`
2. Replace the entire file with the following code

```lua
local function hideText()
    exports['vms_notifyv2']:HideTextUI()
end

local function drawText(text, position)
    exports['vms_notifyv2']:ShowTextUI(text)
end

local function changeText(text, position)
    exports['vms_notifyv2']:UpdateTextUI(text)
end

local function keyPressed()
    exports['vms_notifyv2']:HideTextUI()
end

RegisterNetEvent('qb-core:client:DrawText', function(text, position)
    drawText(text)
end)

RegisterNetEvent('qb-core:client:ChangeText', function(text, position)
    changeText(text)
end)

RegisterNetEvent('qb-core:client:HideText', function()
    hideText()
end)

RegisterNetEvent('qb-core:client:KeyPressed', function()
    keyPressed()
end)

local createQbExport = require 'bridge.qb.shared.export-function'

createQbExport('DrawText', drawText)
createQbExport('ChangeText', changeText)
createQbExport('HideText', hideText)
createQbExport('KeyPressed', keyPressed)
```

</details>

<details>

<summary>ox_lib</summary>

### Notification

1. Navigate to `ox_lib/resource/interface/client/notify.lua`
2. Find function `lib.notify`
3. Replace the function with the one below

```lua
function lib.notify(data)
    if data.type and data.type == "inform" then
        data.type = "info"
    end
    
    exports['vms_notifyv2']:Notification({
        title = data.title,
        description = data.description,
        time = data.duration,
        color = data.iconColor,
        icon = data.icon,
        preset = data.type,
    })
end
```

### TextUI

1. Navigate to `ox_lib/resource/interface/client/textui.lua`
2. Find function `lib.showTextUI`
3. Replace the function with the one below

```lua
function lib.showTextUI(text, options)
    if currentText == text then return end

    if not options then options = {} end

    options.text = text
    currentText = text

    exports['vms_notifyv2']:ShowTextUI(currentText)

    isOpen = true
end
```

4. Find function `lib.hideTextUI`
5. Replace the function with the one below

```lua
function lib.hideTextUI()
    exports['vms_notifyv2']:HideTextUI()

    isOpen = false
    currentText = nil
end
```

</details>

<details>

<summary>TX Admin</summary>

### Announcement

1. Navigate to `txAdmin/resource/sv_main.lua`
2. Find function `TX_EVENT_HANDLERS.announcement`
3. Replace the function with the one below

```lua
TX_EVENT_HANDLERS.announcement = function(eventData)
    local authorName = cvHideAdminInMessages and txServerName or eventData.author or 'anonym'
    if not cvHideAnnouncement then
        TriggerClientEvent("vms_notifyv2:TopNotification", -1, {
            title = "ANNOUNCEMENT",
            description = eventData.message,
            time = 15000,
            color = "#ffc31f",
            icon = "fa-solid fa-bullhorn",
        })
    end
    TriggerEvent('txsv:logger:addChatMessage', 'tx', '(Broadcast) '..authorName, eventData.message)
end
```

### Restart

1. Navigate to `txAdmin/resource/sv_main.lua`
2. Find function `TX_EVENT_HANDLERS.scheduledRestart`
3. Replace the function with the one below

```lua
TX_EVENT_HANDLERS.scheduledRestart = function(eventData)
    if not cvHideScheduledRestartWarning then
        TriggerClientEvent("vms_notifyv2:TopNotification", -1, {
            title = "RESTART",
            description = eventData.translatedMessage,
            time = 15000,
            color = "#ff1f39",
            icon = "fa-solid fa-power-off",
        })
    end
    TriggerEvent('txsv:logger:addChatMessage', 'tx', '(Broadcast) txAdmin', eventData.translatedMessage)
end
```

</details>
