qbcore
Last updated
NM1 Notification Override (QBCore) -- --[[ Setup Instructions:
Place this file in the qb-core/client/ resource directory and name it nm1notify.lua.
Edit the fxmanifest.lua file inside qb-core.
Append the following line at the end of the manifest to guarantee proper load order:
client_script 'nm1notify.lua'
Restart the server to apply the changes. --]]
Last updated
local originalNotify = QBCore.Functions.Notify
QBCore.Functions.Notify = function(text, texttype, length)
if GetResourceState("nm1_notification") == "started" then
local message = text
local title = 'Notification'
-- Handle table-based notify calls
if type(text) == 'table' then
message = text.text or text.caption or ''
title = text.title or title
end
local notifyType = texttype or 'info'
-- Normalize QBCore types β nm1 types
if notifyType == 'primary' then notifyType = 'info' end
if notifyType == 'warning' then notifyType = 'warning' end
if notifyType == 'error' then notifyType = 'error' end
if notifyType == 'success' then notifyType = 'success' end
exports['nm1_notification']:Notify({
title = title,
message = message,
type = notifyType,
duration = length or 5000,
theme = 'light' -- change to 'light' if needed
})
else
-- Fallback to default QBCore notify
originalNotify(text, texttype, length)
end
end
local originalNotify = QBCore.Functions.Notify
QBCore.Functions.Notify = function(text, texttype, length)
if GetResourceState("nm1_notification") == "started" then
local message = text
local title = 'Notification'
-- Handle table-based notify calls
if type(text) == 'table' then
message = text.text or text.caption or ''
title = text.title or title
end
local notifyType = texttype or 'info'
-- Normalize QBCore types β nm1 types
if notifyType == 'primary' then notifyType = 'info' end
if notifyType == 'warning' then notifyType = 'warning' end
if notifyType == 'error' then notifyType = 'error' end
if notifyType == 'success' then notifyType = 'success' end
exports['nm1_notification']:Notify({
title = title,
message = message,
type = notifyType,
duration = length or 5000,
theme = 'dark' -- change to 'light' if needed
})
else
-- Fallback to default QBCore notify
originalNotify(text, texttype, length)
end
end