# 404-AdvancedNotify

#### Step 1: **Ensure 404-AdvancedNotify**

1. **Installation**: Ensure that `404-AdvancedNotify` is added to the server’s resources folder. The typical steps to do this would be:
   * Download the `404-AdvancedNotify` repository.
   * Place it inside your server's `resources` directory.
   * Add the resource to the `server.cfg` file by adding the line:

     ```
     ensure 404-AdvancedNotify
     ```

#### Step 2: **Modify Notify**

For ESX replace the **`Notify`** function inside **`ESX_NOTIFY/Notify.lua`** with the new code.

**Original Code (to be replaced):**

```lua
local function Notify(notificatonType, length, message, title, position)
    if Debug then
        print("1 ".. tostring(notificatonType))
        print("2 "..tostring(length))
        print("3 "..message)
        print("4 "..tostring(title))
        print("5 "..tostring(position))
    end

    if type(notificatonType) ~= "string" then
        notificatonType = "info"
    end

    if type(length) ~= "number" then
        length = 3000
    end

    if not possiblePosition[position] then
        position = Config.position or "middle-right"
    end

    if Debug then
        print("6 ".. tostring(notificatonType))
        print("7 "..tostring(length))
        print("8 "..message)
        print("9 "..tostring(title))
        print("10 "..tostring(position))
    end

    if type(message) == "string" then
        message = message:gsub("~br~", "<br>")
    end

    SendNuiMessage(json.encode({
        type = notificatonType or "info",
        length = length or 5000,
        message = message or "ESX-Notify",
        title = title or "New Notification",
        position = position,
        notificationSoundEnabled = Config.notificationSoundEnabled or false
    }))
end
```

**Replaced Code:**

```lua
local function Notify(notificatonType, length, message, title, position)
    if Debug then
        print("1 ".. tostring(notificatonType))
        print("2 "..tostring(length))
        print("3 "..message)
        print("4 "..tostring(title))
        print("5 "..tostring(position))
    end

    if type(notificatonType) ~= "string" then
        notificatonType = "info"
    end

    if type(length) ~= "number" then
        length = 3000
    end

    if not possiblePosition[position] then
        position = Config.position or "middle-right"
    end

    if Debug then
        print("6 ".. tostring(notificatonType))
        print("7 "..tostring(length))
        print("8 "..message)
        print("9 "..tostring(title))
        print("10 "..tostring(position))
    end

    if type(message) == "string" then
        message = message:gsub("~br~", "<br>")
    end

    exports['404-AdvancedNotify']:ESXNotify(notificatonType, length, message, title, position)
end
```

#### &#x20;For **(Qbox)** replace the **`lib.notify`** function inside **`ox_lib/resource/interface/client/notify.lua`** with the new code.

**Original Code (to be replaced):**

```lua
function lib.notify(data)
    local sound = settings.notification_audio and data.sound
    data.sound = nil
    data.position = data.position or settings.notification_position

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

    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
```

**Replaced Code:**

```lua
function lib.notify(data)
    exports['404-AdvancedNotify']:LibNotify({
        description = data.description,
        duration = data.duration,
        type = data.type,
    })
end
```

#### **For QBCore** replace the **`QBCore.Functions.Notify`** function inside `qb-core/client/functions.lua` with the new code.

**Original Code (to be replaced):**

```lua
function QBCore.Functions.Notify(text, texttype, length, icon)
    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
```

**Replaced Code:**

```lua
function QBCore.Functions.Notify(text, texttype, length)
    exports['404-AdvancedNotify']:Notify('', text, texttype, length)
end
```

#### Bank Notifications&#x20;

use this event to send a bank notiifcation&#x20;

```lua
TriggerClientEvent('404-AdvancedNotify:bank', source, 'Your message')
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://errorscripts.gitbook.io/errorscript/products/404-advancednotify.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
