Skip to main content

Setup Notification System in Framework

S1nScripts Logo

To integrate the notification system into your ESX framework, you need to modify the ESX.ShowNotification function located in es_extended/client/functions.lua on line 73.

Here is the original code:

function ESX.ShowNotification(message, type, length)
if GetResourceState("esx_notify") ~= "missing" then
return exports["esx_notify"]:Notify(type, length, message)
end

print("[^1ERROR^7] ^5ESX Notify^7 is Missing!")
end

Replace it with the following code:

function ESX.ShowNotification(message, type, length, position, title)
TriggerEvent("s1n_notify:notify", {
type = type or "success",
title = title or "Notification",
message = message,
duration = length,
theme = "colorful",
position = position or "top-right"
})
end

Note that you will need to modify any calls to the ESX.ShowNotification function in your scripts to match the new parameters. Here's an example:

ESX.ShowNotification("Hello everyone!", "success", 5000, "top-right", "Title")

To integrate the notification system into your Qbcore framework, you need to modify the QBCore.Functions.Notify function located in qb-core/client/functions.lua on line 88.

Here is the original code:

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 the following code:

function QBCore.Functions.Notify(message, type, length, position, title)
TriggerEvent("s1n_notify:notify", {
type = type or "success",
title = title,
message = message,
duration = length,
theme = "colorful",
position = position or "top-right"
})
end

Note that you will need to modify any calls to the QBCore.Functions.Notify function in your scripts to match the new parameters. Here's an example:

QBCore.Functions.Notify("Hello everyone !", "success", 5000, "top-right", "Title")