Exports / Events

This page documents the available exports and events for the `v42-notify` notification system.

Client-side

🔧 Export: exports['v42-notify']:notify

exports['v42-notify']:notify(text, textType, time)

Explanation of parameters:

  • text

    Required; string or table

    • If a string is passed: it is used as the main notification message.

    • If a table is passed:

      • text — main text

      • caption — optional sub-heading

  • textType

    Optional; string, boolean, or number Determines the style of the notification:

    • true = "success"

    • false or 0 = "error"

    • Invalid or missing = Config.DefaultNotify or "info" Must be defined in Config.Notifications.

  • time

    Optional; number Duration to show the notification (in milliseconds). Default is 5000.


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:

  • targetPlayerId

    Required; number The server ID of the player who should receive the notification.

  • text

    Required; string or table The content of the notification. Can be a string or a table: { text = "Message", caption = "Optional Subtitle" }

  • textType

    Optional; string, boolean, or number Style of the notification (info, success, etc.). Booleans auto-map to success/error. Falls back to default if invalid.

  • time

    Optional; number Time 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