Page cover

Installation

Installation

  1. To install sd-notify, drag and drop the file into your resources folder, and ensure it.

Displaying a Notification

Client-Side

exports['sd-notify']:Notify(title, text, type, length, icon, sound)

Server-Side

TriggerClientEvent('sd-notify:Notify', source, title, text, type, length, icon, sound)

Types:

  • success (green)

  • primary (blue)

  • warning (yellow)

  • error (red)

Length:

  • 1000 - 1 second.

If Length, Icon, Sound remain undefined, it will default to the things set in the config.js If 'Title' is simply nothing like this: exports['sd-notify']:Notify(' ', 'You Failed!, 'error', 2000)' then it will default to a standard message for the type, eg. if it's error it will say Error as the title and so on.

Using your own sound

Create a short sound snippet and save it to the sounds directory. Make sure it's a .ogg file, since this will have the least filesize for a better load time. But you can use .wav or .mp3. When you want to use this in your notification, make sure you only use filename and file extension e.g. audio_name.ogg

exports['sd-notify']:Notify('SOMETHING WENT WRONG', 'You Failed!', 'error', 5000, 'fa-solid fa-bomb', 'error_sound.ogg')

Examples & Integration

Client-Side Integration Example:

local function PlaceBomb(success)
    if success then
        bombplant()
    else
        exports['sd-notify']:Notify('SOMETHING WENT WRONG', 'You Failed!', 'error', 5000)
    end
end

Server-Side Integration Example:

local function DoSomething()
    local hasMoney = GetPlayerAccountFunds(src, 'money', Config.RunCost)
    if hasMoney <= Config.RunCost then
        TriggerClientEvent('sd-notify:Notify', source, 'SOMETHING WENT WRONG', "You don't have enough cash!", 'error', 5000)
        return
    end

    TriggerEvent('sd-oxyrun:server:startrun')
end

Quick QBCore Integration: Find QBCore.Function.Notify (qb-core/client/functions.lua) and replace what's there, with the following export like this, since QBCore doesn't natively have a title, we'll stick to what was advised above and just leave the Title field blank.

function QBCore.Functions.Notify(text, texttype, length)
    exports['sd-notify']:Notify('', text, texttype, length)
end

Last updated