# AN Notify

## [🛒 Buy Script](https://a-n.tebex.io/package/5219046)

<div align="center"><figure><img src="/files/enFCy9cFhIMpub3W1L5U" alt="AN Interaction Menu"><figcaption><p><strong>iOS Inspired FiveM Notification System</strong> | Product Price: <strong>4.99 EUR + Tebex Taxes</strong> / Unencrypted Version: <strong>14.99 EUR + Tebex Taxes</strong></p></figcaption></figure></div>

## How to use?

### Simple Notification Usage:&#x20;

Client Side:

```lua
exports["an_notify"]:Notify(TITLE,TEXT,STYLE,AUTHOR,ICON,DURATION,USE_SOUND)
```

SERVER SIDE

```lua
TriggerClientEvent("an_notify:Notify",PLAYER_ID,TITLE,TEXT,STYLE,AUTHOR,ICON,DURATION,USE_SOUND)
```

* **PLAYER\_ID:** \[ Only required when triggering the notification from server side ] ID of the player who should receive the notification
* **TITLE:** Notification Title ( must be short )
* **TEXT:** Content of the notification ( can be of any size )
* **STYLE:** Can be one of the following: "success", "primary", "danger", "dark" or "light"
* **AUTHOR:** The small text in the bottom right of the notification
* **ICON:** You must use an icon from Font Awesome: <https://fontawesome.com/icons> → You only copy the classes, for example: For this to work: , you only put this: "fa-solid fa-person-rifle"
* **DURATION:** TIME in MS
* **USE\_SOUND:** Enable/Disable Sound on this notification ( can be either true or false )

### Clickable Notification Usage:&#x20;

CLIENT SIDE:

```lua
exports["an_notify"]:NotifyClickable(TITLE,TEXT,STYLE,AUTHOR,ICON,DURATION,USE_SOUND,EVENT,PARAMS,EVENT_TYPE,CLOSEUI)
```

SERVER SIDE:

```lua
TriggerClientEvent("an_notify:Notify",PLAYER_ID,TITLE,TEXT,STYLE,AUTHOR,ICON,DURATION,USE_SOUND,EVENT,PARAMS,EVENT_TYPE,CLOSEUI)
```

* **PLAYER\_ID**: \[ Only required when triggering the notification from server side ] ID of the player who should receive the notification
* <mark style="color:red;">**THE FIRST 7 ARGUMENTS ARE THE SAME AS ABOVE**</mark>
* **EVENT:** Event you want to trigger once the notification is clicked
* **PARAMS:** A Parameter passed as a table for the event, something like:\
  `{ param1 = val1, param2 = val2 }`
* **EVENT\_TYPE:** Can be Either "client" or "server"
* **CLOSEUI:** Whether to close the UI after clicking the notification

## Replacing ESX Notification

1. Go to: `es_extended/client/functions.lua`
2. Find this function:

```lua
function ESX.ShowNotification(message, type, length)
    if Config.NativeNotify then
        BeginTextCommandThefeedPost('STRING')
        AddTextComponentSubstringPlayerName(message)
        EndTextCommandThefeedPostTicker(0, 1)
    else
        exports["esx_notify"]:Notify(type, length, message)
    end
end
```

3. Replace it with this one:

```lua
function ESX.ShowNotification(message, type, length)
    if type == "info" then
        type = "primary"
    elseif type == "error" then
        type = "danger"
    elseif type == nil then
        type = "primary"
    end

    exports["an_notify"]:Notify("NOTIFICATION",message,type,"System",nil,length,true)
    -- if Config.NativeNotify then
    --    BeginTextCommandThefeedPost('STRING')
    --    AddTextComponentSubstringPlayerName(message)
    --    EndTextCommandThefeedPostTicker(0, 1)
    -- else
    --    exports["an_notify"]:Notify(type, length, message)
    -- end
end
```

## Replacing QBCore Notification

1. Open this file: `qbcore/main/client/functions.lua`
2. Find this function:

```lua
function QBCore.Functions.Notify(text, texttype, length)
    if type(text) == "table" then
        local ttext = text.text or 'Placeholder'
        local caption = text.caption or 'Placeholder'
        texttype = texttype or 'primary'
        length = length or 5000
        SendNUIMessage({
            action = 'notify',
            type = texttype,
            length = length,
            text = ttext,
            caption = caption
        })
    else
        texttype = texttype or 'primary'
        length = length or 5000
        SendNUIMessage({
            action = 'notify',
            type = texttype,
            length = length,
            text = text
        })
    end
end
```

3. Replace it with this one:

```lua
function QBCore.Functions.Notify(text, texttype, length)
    if texttype == "error" then
        texttype = "danger"
    end
    if type(text) == "table" then
        local ttext = text.text or 'Placeholder'
        local caption = text.caption or 'Placeholder'
        texttype = texttype or 'primary'
        length = length or 5000
        exports["an_notify"]:Notify(caption,ttext,texttype,"System",nil,length,true)
        -- SendNUIMessage({
        --     action = 'notify',
        --     type = texttype,
        --     length = length,
        --     text = ttext,
        --     caption = caption
        -- })
    else
        texttype = texttype or 'primary'
        length = length or 5000
        exports["an_notify"]:Notify("NOTIFICATION",text,texttype,"System",nil,length,true)
        -- SendNUIMessage({
        --     action = 'notify',
        --     type = texttype,
        --     length = length,
        --     text = text
        -- })
    end
end
```

## Example Snippets:

Here are some examples to get you going, these are the ones used in the [**Demonstration Video**](https://www.youtube.com/watch?v=KA1o45D-glA).\
You can add this code to any client file in order to test the notification system.

#### EXAMPLE OF SIMPLE NOTIFICATION

```lua
RegisterCommand('test', function(src,args,raw)
    Notify("ERROR","You do not have enough money","danger","System","fa-solid fa-sack-xmark",15000,true)
    Citizen.Wait(3000)
    Notify("Payday","<b>$ 1,000</b> was added to your bank account","success","Maze Bank","fa-solid fa-money-check-dollar",15000,true)
    Citizen.Wait(3000)
    Notify("Notification","You found a gold ring in the trash bin.","primary","Server","fa-solid fa-dumpster",15000,true)
    Citizen.Wait(3000)
    Notify("Incoming Call","Batman is calling you","dark","Phone","fa-solid fa-phone-volume",15000,true)
    Citizen.Wait(3000)
    Notify("DISCORD LIGHT MODE","R.I.P your eyes","light","System","fa-regular fa-face-dizzy",15000,true)
end)
```

#### EXAMPLE OF CLICKABLE NOTIFICATION

```lua
RegisterCommand('test2', function(src,args,raw)
    NotifyClickable("Twitter","xXxDem0nSlayeRxXx replied to your tweet.<br/><i class='fa-solid fa-hand-pointer'></i> Click this notification to open your phone.<br/><br/>","primary",nil,"fa-brands fa-twitter",1000000,true,"an_notify:triggerdemo",{ 
        param1 = "this is a string that is saved as the first parameter for the event",
        param2 = "this is a string that is saved as the second parameter for the event", 
    }, "client", true)
end)

-- EVENT THAT WILL BE TRIGGERED BY THE CLICKABLE NOTIFICATION
RegisterNetEvent("an_notify:triggerdemo", function(data)
    ExecuteCommand("phone")
    print(data.param1)
    print(data.param2)
end)
```


---

# 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://a-n.gitbook.io/docs/an-notify.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.
