Exports
Use STG Hud notifications, progress bar, key prompts, announcements and nitro from your own scripts.
Other resources can use the Hud's notifications, progress bar, key prompts and announcements, so every script on your server shares one look.
Client exports
showHud / hideHud
exports['stg-hud']:hideHud()
exports['stg-hud']:showHud()Hides or shows the whole HUD, for example during a cutscene or while a menu is open.
Notify
exports['stg-hud']:Notify({
type = 'success',
title = 'Transfer Complete',
message = 'The money has been sent.',
duration = 5000,
})Prop
Type
Nothing is shown when Config.Features.notifications is false.
HelpNotify / HideHelpNotify
exports['stg-hud']:HelpNotify('E', 'Open trunk')
exports['stg-hud']:HideHelpNotify()Shows a key prompt with the key and a short text until you hide it. Only one prompt shows at a time: a second HelpNotify is ignored until HideHelpNotify is called.
startProgress / cancelProgress
exports['stg-hud']:startProgress(5000, 'Repairing...', {
freeze = true,
anim = { dict = 'mini@repair', lib = 'fixing_a_player' },
prop = 'prop_tool_wrench',
onFinish = function()
-- finished
end,
onCancel = function()
-- cancelled
end,
})
exports['stg-hud']:cancelProgress()Prop
Type
startProgress does not wait: it returns right away, so put your code in onFinish and onCancel. The player can cancel with Backspace or X, and cancelProgress cancels from code. Starting a new bar cancels the one already running.
When Config.Features.progressBar is false, startProgress returns without showing a bar and neither callback runs.
Announcement
exports['stg-hud']:Announcement({
name = 'Admin Team',
title = 'SERVER ANNOUNCEMENT',
message = 'Maintenance starts in 10 minutes.',
duration = 15000,
})Shows an announcement banner to this player only. Missing fields fall back to DefaultName, DefaultTitle and DefaultDuration from Config.Announcement. To reach every player, use the server export below.
useNos
exports['stg-hud']:useNos()Starts the nitro install, the same as using the nos item: on the nearest vehicle, or on the player's current vehicle when installOutsideOnly is false. One nos item is removed from the player.
Server exports
SendAnnouncement
exports['stg-hud']:SendAnnouncement(5000, 'Server restart in 5 minutes!', 'System', 'ANNOUNCEMENT')Shows a banner to every player. The arguments are duration in milliseconds, message, sender name and title. Any argument left out uses the Config.Announcement default. It is skipped while another announcement is on screen.
Events
To send a notification from the server, trigger this client event:
TriggerClientEvent('stg-notify:notify', source, 'success', 'Your car has been repaired.', 'Mechanic', 5000)The arguments are type, message, title and duration. You can also pass one table with the same fields as the Notify export.
Still having trouble?
Open a ticket on our Discord. Our team answers around 15 hours a day.