Notificaciones personalizables para FIVEM. Imita las notificaciones nativas de GTAV, pero permite más personalización
css
a ui/css/custom.css
~r~
, ~b~
, ~h~
, etc.) exports . bulletin : Send ( message , timeout , position , progress , theme , exitAnim , flash )
-- or
exports . bulletin : Send ({
message = ' Message ' ,
timeout = 5000 ,
theme = ' success '
...
})
exports . bulletin : SendAdvanced ( message , title , subject , icon , timeout , position , progress , theme , exitAnim , flash )
-- or
exports . bulletin : SendAdvanced ({
message = ' Some Message ' ,
title = ' Some Title ' ,
subject = ' Some Subtitle ' ,
icon = ' CHAR_BANK_MAZE ' ,
...
})
local pinID = exports . bulletin : SendPinned ({
type = ' advanced ' , -- or 'standard'
message = ' This is pinned! ' ,
title = ' Title ' ,
subject = ' Subject ' ,
icon = ' CHAR_BANK_MAZE '
})
-- unpin
exports . bulletin : Unpin ( pinID )
-- unpin multiple
exports . bulletin : Unpin ({ pinID1 , pinID2 , pinID3 , ... })
-- unpin all
exports . bulletin : Unpin ()
-- update content
exports . bulletin : UpdatePinned ( pinID , options )
Estos son métodos abreviados para enviar una notificación temática. Toman los mismos parámetros / tabla que el método Send()
:
-- Send standard success notification
exports . bulletin : SendSuccess ( ... )
-- Send standard info notification
exports . bulletin : SendInfo ( ... )
-- Send standard warning notification
exports . bulletin : SendWarning ( ... )
-- Send standard error notification
exports . bulletin : SendError ( ... )
Todos los métodos se pueden activar tanto del cliente como del servidor:
-- standard
TriggerClientEvent ( ' bulletin:send ' , source , ... )
-- advanced
TriggerClientEvent ( ' bulletin:sendAdvanced ' , source , ... )
Estos se pasan como parámetros individuales o en una tabla:
parámetro | tipo | por defecto | opción | opcional | descripción |
---|---|---|---|---|---|
message | string | NO | El mensaje para enviar. Puede ser una cadena o html válido | ||
timeout | integer | 5000 | SÍ | La duración en ms para mostrar la notificación | |
position | string | "bottomleft" | "bottomleft" , "topleft" , "topright" "bottomright" , "bottom" , "top" | SÍ | La publicación de la notificación |
progress | boolean | false | true , false | SÍ | Si mostrar el progreso del tiempo de espera de notificación |
theme | string | "default" | "default" , "success" , "info" , "warning" , "error" | SÍ | El tema de la notificación |
exitAnim | string | "fadeOut" | Ver animate.css para las opciones | SÍ | La animación utilizada para ocultar la notificación |
flash | boolean | false | SÍ | Hace que la notificación parpadee | |
title | string | NO | El título de la notificación (solo avanzado) | ||
subject | string | NO | El sujeto / subtítulo de la notificación (solo avanzado) | ||
icon | string | NO | La imagen para usar (solo avanzada) |
Config . Timeout = 5000 -- Overridden by the `timeout` param
Config . Position = " bottomleft " -- Overridden by the `position` param
Config . Progress = false -- Overridden by the `progress` param
Config . Theme = " default " -- Overridden by the `theme` param
Config . Queue = 5 -- No. of notifications to show before queueing
Config . Stacking = true
Config . ShowStackedCount = true
Config . AnimationOut = " fadeOut " -- Default exit animation - overriden by the `exitAnim` param
Config . AnimationTime = 500 -- Entry / exit animation interval
Config . FlashCount = 5 -- No. of times the notification blinks when `flash` param is used
Config . SoundFile = false -- Sound file stored in ui/audio used for notification sound. Leave as false to disable.
Config . SoundVolume = 0.4 -- 0.0 - 1.0
Config . Pictures = {
-- advanced notification icons
}
Para agregar su propia imagen personalizada, cargue una imagen jpg
64x64
al directorio ui/images
y agregue el código personalizado y el nombre de archivo a la tabla Config.Pictures
en config.lua
,
Cargue my_custom_icon_image.jpg
en el directorio ui/images
y use MY_CUSTOM_ICON_CODE
(¡sin espacios!) Como clave.
Config . Pictures = {
...
MY_CUSTOM_ICON_CODE = " my_custom_icon_image.jpg " -- Add this
}
Luego use el código personalizado en la llamada de notificación:
exports . bulletin : SendAdvanced ( " Message " , " Title " , " Subject " , " MY_CUSTOM_ICON_CODE " )
Puede habilitar un sonido de notificación cargando un archivo de sonido personalizado en el directorio ui/audio
y editando la configuración para usarlo:
Config . SoundFile = ' my_notification_sound.mp3 '
Config . SoundVolume = 0.4
Archivos de audio válidos: .mp3
, .ogg
, .wav
El boletín admite el siguiente formato:
n = new line
~ r ~ = Red
~ b ~ = Blue
~ g ~ = Green
~ y ~ = Yellow
~ p ~ = Purple
~ o ~ = Orange
~ u ~ = Black
~ w ~ = White
~ h ~ = Bold Text
También puede usar HTML para colores:
exports . bulletin : Send ( " <span class='r'>I am red</span> and <span class='y'>I am yellow</span> " )
o cualquier html que te guste
exports . bulletin : Send ( " <h1>Some Title</h1><p class='paragraph'>Some text</p><footer>Some footer text</footer> " )
Para enviar una notificación fijada, deberá almacenar el pin_id
de la notificación para que pueda descargarla más tarde.
local pinID = exports . bulletin : SendPinned ({
type = ' advanced ' -- or 'standard'
message = ' This is pinned! '
})
Luego, para descargarlo, simplemente pase el valor almacenado al método Unpin()
:
exports . bulletin : Unpin ( pinID )
El método Unpin()
también acepta una table
de ID de PIN:
exports . bulletin : Unpin ({ pinned1 , pinned2 , pinned3 })
u omitir el parámetro para descargar todo:
exports . bulletin : Unpin ()
También puede actualizar el contenido de una notificación fija:
-- Send pinned notification
local pinID = exports . bulletin : SendPinned ({
type = ' advanced ' ,
message = ' This is pinned! ' ,
title = ' Title ' ,
subject = ' Subject ' ,
icon = ' CHAR_BANK_MAZE ' ,
theme = ' success '
})
-- Update it's content
exports . bulletin : UpdatePinned ( pinID , {
message = ' Updated message! ' ,
title = ' Updated title ' ,
subject = ' Updated subject ' ,
icon = ' CHAR_TREVOR ' ,
theme = ' error ' ,
flash = true
})
Solo el message
, title
, subject
, icon
, theme
y las opciones flash
se pueden actualizar en este momento.
Las notificaciones fijadas no están en cola, por lo que, por ejemplo, si establece Config.Queue
en 5
y tiene 2
notificaciones fijadas, obtendrá un máximo de 7
notificaciones que se muestran en cualquier momento.
Si está utilizando ESX
, puede obtener bulletin
para anular las notificaciones editando las funciones apropiadas en es_extended/client/functions.lua
:
ESX . ShowNotification = function ( msg )
-- SetNotificationTextEntry('STRING')
-- AddTextComponentString(msg)
-- DrawNotification(0,1)
exports . bulletin : Send ( msg )
end
ESX . ShowAdvancedNotification = function ( sender , subject , msg , textureDict , iconType , flash , saveToBrief , hudColorIndex )
-- if saveToBrief == nil then saveToBrief = true end
-- AddTextEntry('esxAdvancedNotification', msg)
-- BeginTextCommandThefeedPost('esxAdvancedNotification')
-- if hudColorIndex then ThefeedNextPostBackgroundColor(hudColorIndex) end
-- EndTextCommandThefeedPostMessagetext(textureDict, textureDict, false, iconType, sender, subject)
-- EndTextCommandThefeedPostTicker(flash or false, saveToBrief)
exports . bulletin : SendAdvanced ( msg , sender , subject , textureDict )
end
boletín Copyright (c) 2021 Mobius1 Este programa es un software gratuito: puede redistribuirlo y/o modificarlo bajo los términos de la Licencia Pública General de GNU publicada por Free Software Foundation, ya sea la versión 3 de la licencia o (a su opción) cualquier versión posterior. Este programa se distribuye con la esperanza de que sea útil, pero sin ninguna garantía; Sin siquiera la garantía implícita de comerciabilidad o estado físico para un propósito particular. Vea la Licencia Pública General de GNU para más detalles. Debería haber recibido una copia de la Licencia Pública General de GNU junto con este programa. |