Exports and Events
Here is the event and export to use in your scripts to display notifications.
Via export (Client-Side)
exports['PNotif']:sendNotification({
title = 'Titre de la notification',
message = 'Message de la notification',
type = 'success',
duration = 5000
})Via Event (Serveur to Client)
TriggerClientEvent('pnotif:sendNotification', playerId, {
title = 'Titre de la notification',
message = 'Message de la notification',
type = 'info',
duration = 4000
})Example
RegisterCommand('notifyServerTest', function(source, args, rawCommand)
TriggerClientEvent('pnotif:sendNotification', source, {
title = '~r~Titre~s~ ~g~Coloré~s~',
message = 'Ceci est un test avec ~b~titre coloré~s~ depuis le serveur',
type = 'success',
duration = 5000
})
TriggerClientEvent('pnotif:sendNotification', source, {
title = '~y~Attention~s~',
message = 'Message ~o~important~s~ avec titre ~bold~en gras~s~',
type = 'warning',
duration = 5000
})
TriggerClientEvent('pnotif:sendNotification', source, {
title = '~lg~Super~s~ ~bold~Succès~s~',
message = 'Opération réussie avec ~g~titre en couleur~s~',
type = 'info',
duration = 5000
})
end)
You can always use esx.ShowNotification.
If you make any changes in your es_extended, go to the file es_extended/client/functions.lua.
Replace
ESX.ShowNotification = function(msg)
SetNotificationTextEntry('STRING')
AddTextComponentString(msg)
DrawNotification(0,1)
end
Then, add this.
function ESX.ShowNotification(message, type, data)
if GetResourceState("PNotif") ~= "missing" then
local _data = data or {}
return exports['PNotif']:sendNotification({
message = message,
type = type or 'info',
title = _data.title or 'Notification',
duration = _data.duration or 4000
})
end
endLast updated

