chore: types

mostly types anyway.
This commit is contained in:
Linden
2023-07-31 16:29:27 +10:00
parent f11668b95c
commit 9d98b9aada
6 changed files with 59 additions and 51 deletions

View File

@@ -1,5 +1,5 @@
---@alias NotificationPosition 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left' | 'center-right' | 'center-left'
---@alias NotificationType 'inform' | 'warning' | 'success' | 'error'
---@alias NotificationType 'info' | 'warning' | 'success' | 'error'
---@class NotifyProps
---@field id? string
@@ -12,7 +12,9 @@
---@field icon? string | {[1]: IconProp, [2]: string};
---@field iconColor? string;
---`client`
---@param data NotifyProps
---@diagnostic disable-next-line: duplicate-set-field
function lib.notify(data)
SendNUIMessage({
action = 'notify',
@@ -33,7 +35,7 @@ function lib.defaultNotify(data)
-- Backwards compat for v3
data.type = data.status
if data.type == 'inform' then data.type = 'info' end
return lib.notify(data)
return lib.notify(data --[[@as NotifyProps]])
end
RegisterNetEvent('ox_lib:notify', lib.notify)

View File

@@ -1,44 +1,44 @@
if GetConvarInt('ox:txAdminNotifications', false) == 1 then
if GetConvar('txAdmin-hideDefaultAnnouncement', 'false') == 'true' then
AddEventHandler('txAdmin:events:announcement', function(eventData)
TriggerClientEvent('ox_lib:notify', -1, {
id = 'txAdmin:announcement',
title = locale('txadmin_announcement', eventData.author),
description = eventData.message,
duration = 5000
})
end)
end
if GetConvarInt('ox:txAdminNotifications', 0) == 0 then return end
if GetConvar('txAdmin-hideDefaultDirectMessage', 'false') == 'true' then
AddEventHandler('txAdmin:events:playerDirectMessage', function(eventData)
TriggerClientEvent('ox_lib:notify', eventData.target, {
id = 'txAdmin:playerDirectMessage',
title = locale('txadmin_dm', eventData.author),
description = eventData.message,
duration = 5000
})
end)
end
if GetConvar('txAdmin-hideDefaultWarning', 'false') == 'true' then
AddEventHandler('txAdmin:events:playerWarned', function(eventData)
TriggerClientEvent('ox_lib:alertDialog', eventData.target, {
header = locale('txadmin_warn', eventData.author),
content = locale('txadmin_warn_content', eventData.reason, eventData.actionId),
centered = true
})
end)
end
if GetConvar('txAdmin-hideDefaultScheduledRestartWarning', 'false') == 'true' then
AddEventHandler('txAdmin:events:scheduledRestart', function(eventData)
TriggerClientEvent('ox_lib:notify', -1, {
id = 'txAdmin:scheduledRestart',
title = locale('txadmin_scheduledrestart'),
description = eventData.translatedMessage,
duration = 5000
})
end)
end
if GetConvarInt('txAdmin-hideDefaultAnnouncement', 0) == 1 then
AddEventHandler('txAdmin:events:announcement', function(eventData)
TriggerClientEvent('ox_lib:notify', -1, {
id = 'txAdmin:announcement',
title = locale('txadmin_announcement', eventData.author),
description = eventData.message,
duration = 5000
})
end)
end
if GetConvarInt('txAdmin-hideDefaultDirectMessage', 0) == 1 then
AddEventHandler('txAdmin:events:playerDirectMessage', function(eventData)
TriggerClientEvent('ox_lib:notify', eventData.target, {
id = 'txAdmin:playerDirectMessage',
title = locale('txadmin_dm', eventData.author),
description = eventData.message,
duration = 5000
})
end)
end
if GetConvarInt('txAdmin-hideDefaultWarning', 0) == 1 then
AddEventHandler('txAdmin:events:playerWarned', function(eventData)
TriggerClientEvent('ox_lib:alertDialog', eventData.target, {
header = locale('txadmin_warn', eventData.author),
content = locale('txadmin_warn_content', eventData.reason, eventData.actionId),
centered = true
})
end)
end
if GetConvarInt('txAdmin-hideDefaultScheduledRestartWarning', 0) == 1 then
AddEventHandler('txAdmin:events:scheduledRestart', function(eventData)
TriggerClientEvent('ox_lib:notify', -1, {
id = 'txAdmin:scheduledRestart',
title = locale('txadmin_scheduledrestart'),
description = eventData.translatedMessage,
duration = 5000
})
end)
end