STG ScriptsDocumentation
Notify Pack

Usage

How to show STG Notify Pack notifications, announcements, progress bars and help prompts from your own client and server scripts.

Apart from the announcement commands and txAdmin, Notify Pack only shows what your other scripts send it. They call it through the exports and events below. All exports are client side, except SendAnnouncement, which runs on the server.

Notifications

From a client script

exports['stg-notify']:Notify({
    type = 'success',
    title = 'Bank',
    message = 'You received $500.',
    duration = 5000,
})

Prop

Type

Several notifications can be on screen at once. Each one plays a sound and shows a ring that counts down its duration.

From a server script

Trigger the client event for one player, or -1 for everyone. It takes the same table:

TriggerClientEvent('stg-notify:notify', source, {
    type = 'error',
    title = 'Shop',
    message = 'You do not have enough money.',
    duration = 5000,
})

The event also accepts plain arguments in the order type, message, title, duration. Here the type defaults to info:

TriggerClientEvent('stg-notify:notify', source, 'info', 'Your order is ready.', 'Pizza')

Announcements

To every player (server)

exports['stg-notify']:SendAnnouncement(15000, 'Server restart in 10 minutes.', 'Staff', 'MAINTENANCE')

Prop

Type

While another announcement is showing, the call is ignored.

To one player (server)

TriggerClientEvent('stg-notify:announcement', playerId, 'Staff', 'WARNING', 10000, 'Please read the server rules.')

The arguments are name, title, duration in milliseconds and message.

On this player's screen only (client)

exports['stg-notify']:Announcement({
    name = 'Dispatch',
    title = 'NEW CALL',
    message = 'Robbery in progress at the Fleeca bank.',
    duration = 10000,
})

Fields left out fall back to DefaultName, DefaultTitle and DefaultDuration from the config. This export does not exist when Config.Features.announcement is false.

Commands

CommandWhoEffect
/announce [seconds] [message]Groups in Config.Announcement.permissionShows the message to every player
/announceto [id] [seconds] [message]The same groups, plus the ACE permission command.announcetoShows the message to one player

Both command names can be changed in the config.

Help prompts

exports['stg-notify']:HelpNotify('E', 'Open the trunk')
exports['stg-notify']:HideHelpNotify()

HelpNotify shows a key badge and a message until you call HideHelpNotify. The key is only the text on the badge, so your script still has to listen for the key press itself.

Only one prompt is shown at a time. A second HelpNotify call while one is visible is ignored, so call HideHelpNotify first when you want to change the text.

A typical pattern shows the prompt near a point and hides it when the player walks away:

local point = vector3(215.8, -810.1, 30.7)
local shown = false

CreateThread(function()
    while true do
        local near = #(GetEntityCoords(PlayerPedId()) - point) < 2.0

        if near and not shown then
            exports['stg-notify']:HelpNotify('E', 'Open the trunk')
            shown = true
        elseif not near and shown then
            exports['stg-notify']:HideHelpNotify()
            shown = false
        end

        Wait(250)
    end
end)

Progress bar

exports['stg-notify']:startProgress(5000, 'Eating...', {
    freeze = false,
    anim = { dict = 'mp_player_inteat@burger', lib = 'mp_player_int_eat_burger' },
    prop = 'prop_cs_burger_01',
    onFinish = function()
        TriggerServerEvent('myscript:ate')
    end,
    onCancel = function()
        exports['stg-notify']:Notify({ type = 'error', title = 'Food', message = 'You stopped eating.' })
    end,
})

The arguments are the duration in milliseconds, the label shown on the bar and an options table:

Prop

Type

The export returns right away, so put the code that should run afterwards in onFinish and onCancel.

The player cancels the bar with Backspace, Esc or X. Starting a new bar while one is running cancels the old one first, and its onCancel runs.

To cancel the current bar from your own code:

-- client
exports['stg-notify']:cancelProgress()

-- server
TriggerClientEvent('stg-notify:cancelProgress', playerId)

Preview commands

These commands are open to every player and only show the result on their own screen:

CommandShows
/notifytestA success, an error and an info notification
/announcetestA sample announcement
/progresstestA 5 second progress bar that freezes the player
/helptestA help prompt for 4 seconds

Still having trouble?

Open a ticket on our Discord. Our team answers around 15 hours a day.

Get help on Discord

On this page