Exports / Events
This page documents the available exports and events for the `v42-notify` notification system.
Client-side
NOTE: Ensure the resource is named v42-notify otherwise, the exports will not work as expected.
🔧 Export: exports['v42-notify']:notify
exports['v42-notify']:notify(text, textType, time)
Explanation of parameters:
textRequired;
stringortableIf a string is passed: it is used as the main notification message.
If a table is passed:
text— main textcaption— optional sub-heading
textTypeOptional;
string,boolean, ornumberDetermines the style of the notification:true="success"falseor0="error"Invalid or missing =
Config.DefaultNotifyor"info"Must be defined inConfig.Notifications.
timeOptional;
numberDuration to show the notification (in milliseconds). Default is5000.
Example of usage:
RegisterCommand('playNotification', function()
exports['v42-notify']:notify("This is an info notification!", "info", 5000)
Wait(1000)
exports['v42-notify']:notify("This is a success message!", true, 5000)
Wait(1000)
exports['v42-notify']:notify("Something went wrong.", false, 5000)
Wait(1000)
exports['v42-notify']:notify({
text = "You have earned a reward!",
caption = "Mission Complete"
}, "success", 6000)
end, false)Server-side
🔧 Server Trigger: TriggerClientEvent('v42-notify:notify', ...)
TriggerClientEvent('v42-notify:notify', targetPlayerId, text, textType, time)
Explanation of parameters:
targetPlayerIdRequired;
numberThe server ID of the player who should receive the notification.textRequired;
stringortableThe content of the notification. Can be a string or a table:{ text = "Message", caption = "Optional Subtitle" }textTypeOptional;
string,boolean, ornumberStyle of the notification (info,success, etc.). Booleans auto-map to success/error. Falls back to default if invalid.timeOptional;
numberTime in milliseconds to show the notification. Default:5000
Example of usage:
Server-side
RegisterCommand('notifyPlayer', function(source, args)
local targetId = tonumber(args[1])
if not targetId then
print("Usage: /notifyPlayer [playerId]")
return
end
TriggerClientEvent('v42-notify:notify', targetId, {
text = "You've received a message from the server!",
caption = "Server Notification"
}, "info", 5000)
end, false)Client-side listener
RegisterNetEvent("v42-notify:notify", function(text, textType, time)
exports['v42-notify']:notify(text, textType, time)
end)Last updated
