🟠AN Notify
iOS Inspired & Advanced Notification System

How to use?
Simple Notification Usage:
Client Side:
exports["an_notify"]:Notify(TITLE,TEXT,STYLE,AUTHOR,ICON,DURATION,USE_SOUND)
SERVER SIDE
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:
CLIENT SIDE:
exports["an_notify"]:NotifyClickable(TITLE,TEXT,STYLE,AUTHOR,ICON,DURATION,USE_SOUND,EVENT,PARAMS,EVENT_TYPE,CLOSEUI)
SERVER SIDE:
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
THE FIRST 7 ARGUMENTS ARE THE SAME AS ABOVE
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
Go to:
es_extended/client/functions.lua
Find this function:
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
Replace it with this one:
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
Open this file:
qbcore/main/client/functions.lua
Find this function:
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
Replace it with this one:
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. You can add this code to any client file in order to test the notification system.
EXAMPLE OF SIMPLE NOTIFICATION
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
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)
Last updated