Aller au contenu principal

Configuración

Toda la configuración está en config.lua. El recurso funciona correctamente con los valores por defecto — solo toca lo que necesites cambiar.

Opciones

ClavePor defectoDescripción
Config.Locale'es'Idioma de los textos propios del recurso (/testnotify). 'en' o 'es'. No afecta al texto enviado por otros scripts.
Config.Position'top-right'Posición en pantalla. Opciones: 'top-right', 'top-left', 'top-center', 'bottom-right', 'bottom-left', 'bottom-center'.
Config.DefaultDuration4500Tiempo en pantalla (ms) cuando el script llamante no especifica duración.
Config.MaxVisible5Máximo de notificaciones visibles a la vez. Las más antiguas se eliminan al superarlo.
Config.SoundtrueReproduce un sonido sutil al aparecer cada notificación.
Config.OverrideFrameworktrueReemplaza ESX.ShowNotification y redirige QBCore:Notify / esx:showNotification automáticamente.
Config.DefaultType'info'Tipo de notificación cuando el llamante no especifica ninguno.
Config.Types(tabla)Apariencia por tipo: accent (color barra lateral + glow) e icon para cada uno de success, error, info, warning.

Ejemplo de config.lua

Config.Position = 'top-right'
Config.DefaultDuration = 4500
Config.MaxVisible = 5
Config.Sound = true
Config.OverrideFramework = true

Config.Types = {
success = { accent = '#22c55e', icon = 'check' },
error = { accent = '#ef4444', icon = 'cross' },
info = { accent = '#3b82f6', icon = 'info' },
warning = { accent = '#f59e0b', icon = 'warn' },
}

Uso desde cualquier script cliente

Export directo (recomendado)

exports['fr_notify']:Send('Vehículo guardado.')
exports['fr_notify']:Send({ type = 'success', title = 'Garaje', message = 'Guardado.', duration = 4000 })
exports['fr_notify']:Success('Guardado!', 'Garaje')
exports['fr_notify']:Error('Dinero insuficiente')
exports['fr_notify']:Info('Pulsa E para interactuar')
exports['fr_notify']:Warning('Reinicio en 5 minutos')

Patrón seguro con fallback

Si quieres que tu script funcione aunque fr_notify no esté instalado:

local function Notify(msg, ntype)
if GetResourceState('fr_notify') == 'started' then
exports['fr_notify']:Send({ type = ntype or 'info', message = msg })
else
ESX.ShowNotification(msg) -- fallback ESX
-- QBCore.Functions.Notify(msg, ntype) -- fallback QBCore
end
end

Notify('Contrato aceptado.', 'success')

Desde el servidor

TriggerClientEvent('fr_notify:send', source, { type = 'error', message = 'Estás buscado.' })

Override de framework

Con Config.OverrideFramework = true, fr_notify intercepta:

  • ESX.ShowNotification(msg)
  • TriggerEvent('esx:showNotification', msg)
  • TriggerEvent('QBCore:Notify', msg, type)

Todos los scripts que usen estas llamadas pasan a usar la nueva interfaz automáticamente sin tocar ningún código.

Scripts con framework cacheado

Si un script guarda local ESX = exports...GetSharedObject() antes de que fr_notify arranque, puede saltarse el override. En ese caso usa el export directo con el patrón seguro.

Override total garantizado

Para que el 100% de las notificaciones del servidor usen fr_notify, edita la función nativa del framework:

ESX — en es_extended/client/functions.lua:

function ESX.ShowNotification(message, notifyType, length, title, position)
if GetResourceState('fr_notify') == 'started' then
return exports['fr_notify']:Send({ type = notifyType, title = title, message = message, duration = length })
end
-- cuerpo original como fallback
end