❗Notifications
Location: Shared/config.lua
Config.Notifications = 'ox_lib' -- ox_lib or esx
---Notifications
function Notifi(data)
if Config.Notifications == 'ox_lib' then
lib.defaultNotify({
title = Config.title,
description = data.text or data,
duration = data.duration or 6000,
style = {
backgroundColor = '#292929',
color = '#c2c2c2',
['.description'] = {
color = '#cccccc'
}
},
icon = data.icon or 'car',
iconColor = data.color or '#d46363'
})
elseif Config.Notifications == 'esx' then
TriggerEvent('esx:showNotification', data.text, "info", 3000)
end
end
function NotifiServ(src, data)
if Config.Notifications == 'ox_lib' then
TriggerClientEvent('ox_lib:notify', src, {
title = " " or Config.title,
description = data.text or data,
duration = 6000,
style = {
backgroundColor = '#292929',
color = '#c2c2c2',
['.description'] = {
color = '#cccccc'
}
},
icon = data.icon or "car",
iconColor = data.color or '#d46363'
})
elseif Config.Notifications == 'esx' then
TriggerClientEvent('esx:showNotification', src, data.text, "info", 3000)
end
end
Location: Shared/config.lua Example of OKOK
Config.Notifications = 'okok' -- ox_lib or esx
---Notifications
function Notifi(data)
if Config.Notifications == 'ox_lib' then
lib.defaultNotify({
title = Config.title,
description = data.text or data,
duration = data.duration or 6000,
style = {
backgroundColor = '#292929',
color = '#c2c2c2',
['.description'] = {
color = '#cccccc'
}
},
icon = data.icon or 'car',
iconColor = data.color or '#d46363'
})
elseif Config.Notifications == 'okok' then
local title = Config.title
local message = data.text or data
local time = data.duration or 6000
local type = "info"
exports['okokNotify']:Alert(title, message, time, type)
end
end
function NotifiServ(src, data)
if Config.Notifications == 'ox_lib' then
TriggerClientEvent('ox_lib:notify', src, {
title = " " or Config.title,
description = data.text or data,
duration = 6000,
style = {
backgroundColor = '#292929',
color = '#c2c2c2',
['.description'] = {
color = '#cccccc'
}
},
icon = data.icon or "car",
iconColor = data.color or '#d46363'
})
elseif Config.Notifications == 'okok' then
local title = Config.title
local message = data.text or data
local time = data.duration or 6000
local type = "info"
TriggerClientEvent('okokNotify:Alert', src, title, message, time, type)
end
end
Location: Shared/Config.lua Example of QS notifications:
Config.Notifications = 'qs' -- ox_lib or esx
---Notifications
function Notifi(data)
if Config.Notifications == 'ox_lib' then
lib.defaultNotify({
title = Config.title,
description = data.text or data,
duration = data.duration or 6000,
style = {
backgroundColor = '#292929',
color = '#c2c2c2',
['.description'] = {
color = '#cccccc'
}
},
icon = data.icon or 'car',
iconColor = data.color or '#d46363'
})
elseif Config.Notifications == 'qs' then
local title = Config.title
local message = data.text or data
local time = data.duration or 6000
local type = "info"
exports['qs-notify']:Alert(message, time, type)
end
end
function NotifiServ(src, data)
if Config.Notifications == 'ox_lib' then
TriggerClientEvent('ox_lib:notify', src, {
title = " " or Config.title,
description = data.text or data,
duration = 6000,
style = {
backgroundColor = '#292929',
color = '#c2c2c2',
['.description'] = {
color = '#cccccc'
}
},
icon = data.icon or "car",
iconColor = data.color or '#d46363'
})
elseif Config.Notifications == 'qs' then
local title = Config.title
local message = data.text or data
local time = data.duration or 6000
local type = "info"
TriggerClientEvent('qs-notify:Alert', src, message, time, type)
end
end
Location: Shared/Config.lua Example of QBcore notifications (in most of configs i've forgot both events to client side, heres the fix)
Config.Notifications = 'qb' -- ox_lib or esx
---Notifications
function Notifi(data)
if Config.Notifications == 'ox_lib' then
lib.defaultNotify({
title = Config.title,
description = data.text or data,
duration = data.duration or 6000,
style = {
backgroundColor = '#292929',
color = '#c2c2c2',
['.description'] = {
color = '#cccccc'
}
},
icon = data.icon or 'car',
iconColor = data.color or '#d46363'
})
elseif Config.Notifications == 'qb' then
local message = data.text or data
local type = "info"
QBCore.Functions.Notify(message, type)
end
end
function NotifiServ(src, data)
if Config.Notifications == 'ox_lib' then
TriggerClientEvent('ox_lib:notify', src, {
title = " " or Config.title,
description = data.text or data,
duration = data.duration or 6000,
style = {
backgroundColor = '#292929',
color = '#c2c2c2',
['.description'] = {
color = '#cccccc'
}
},
icon = data.icon or "car",
iconColor = data.color or '#d46363'
})
elseif Config.Notifications == 'qb' then
local message = data.text or data
local duration = data.duration or 6000
local type = "info"
TriggerClientEvent('QBCore:Notify', src, message, type, duration)
end
end
Adding custom notifications explenation: Location: Shared/config.lua
Config.Notifications = 'systemname' --- name for notify system
elseif Config.Notifications == 'systemname' then
local title = Config.title --- notification title
local message = data.text or data --- notification message
local time = data.duration or 6000 --- notification duration
local type = "info" --- notification type
-- export/event with notification ---
-- Client: exports['qs-notify']:Alert(message, time, type)
-- Server: TriggerClientEvent('qs-notify:Alert', src, message, time, type)
Last updated