Notificações personalizáveis para o FIVEM. Imita as notificações nativas do GTAV, mas permite mais personalização
css
para 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 )
Estes são métodos abreviados para enviar notificação temática. Eles pegam os mesmos params / tabela que o 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 os métodos podem ser desencadeados do cliente e do servidor:
-- standard
TriggerClientEvent ( ' bulletin:send ' , source , ... )
-- advanced
TriggerClientEvent ( ' bulletin:sendAdvanced ' , source , ... )
Estes são passados como parâmetros individuais ou em uma tabela:
param | tipo | padrão | opções | opcional | descrição |
---|---|---|---|---|---|
message | string | NÃO | A mensagem para enviar. Pode ser uma string ou html válido | ||
timeout | integer | 5000 | SIM | A duração no ms para exibir a notificação | |
position | string | "bottomleft" | "bottomleft" , "topleft" , "topright" "bottomright" , "bottom" , "top" | SIM | A posição da notificação |
progress | boolean | false | true , false | SIM | Se deve exibir o progresso do tempo limite de notificação |
theme | string | "default" | "default" , "success" , "info" , "warning" , "error" | SIM | O tema da notificação |
exitAnim | string | "fadeOut" | Veja animate.css para as opções | SIM | A animação usada para ocultar a notificação |
flash | boolean | false | SIM | Faz a notificação pisca | |
title | string | NÃO | O título da notificação (somente avançado) | ||
subject | string | NÃO | O assunto / legenda da notificação (somente avançada) | ||
icon | string | NÃO | A imagem a ser usada (somente avançada) |
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 adicionar sua própria imagem personalizada, faça o upload de uma imagem jpg
64x64
ao diretório da ui/images
e adicione o código e o nome do arquivo personalizado à tabela Config.Pictures
em config.lua
,
Carregue my_custom_icon_image.jpg
no diretório ui/images
e use MY_CUSTOM_ICON_CODE
(sem espaços!) Como a chave.
Config . Pictures = {
...
MY_CUSTOM_ICON_CODE = " my_custom_icon_image.jpg " -- Add this
}
Em seguida, use o código personalizado na chamada de notificação:
exports . bulletin : SendAdvanced ( " Message " , " Title " , " Subject " , " MY_CUSTOM_ICON_CODE " )
Você pode ativar um som de notificação enviando um arquivo de som personalizado para o diretório de interface ui/audio
e editando a configuração para usá -lo:
Config . SoundFile = ' my_notification_sound.mp3 '
Config . SoundVolume = 0.4
Arquivos de áudio válidos: .mp3
, .ogg
, .wav
O boletim suporta a seguinte formatação:
n = new line
~ r ~ = Red
~ b ~ = Blue
~ g ~ = Green
~ y ~ = Yellow
~ p ~ = Purple
~ o ~ = Orange
~ u ~ = Black
~ w ~ = White
~ h ~ = Bold Text
Você também pode usar HTML para cores:
exports . bulletin : Send ( " <span class='r'>I am red</span> and <span class='y'>I am yellow</span> " )
ou qualquer html que você goste
exports . bulletin : Send ( " <h1>Some Title</h1><p class='paragraph'>Some text</p><footer>Some footer text</footer> " )
Para enviar uma notificação fixada, você precisará armazenar o pin_id
da notificação para que você possa desenrolá -la mais tarde.
local pinID = exports . bulletin : SendPinned ({
type = ' advanced ' -- or 'standard'
message = ' This is pinned! '
})
Então, para desconhecer, basta passar o valor armazenado para o método Unpin()
:
exports . bulletin : Unpin ( pinID )
O método Unpin()
também aceita uma table
de IDs de pinos:
exports . bulletin : Unpin ({ pinned1 , pinned2 , pinned3 })
ou omitir o parâmetro para desconsiderar tudo:
exports . bulletin : Unpin ()
Você também pode atualizar o conteúdo de uma notificação fixada:
-- 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
})
Somente as opções de message
, title
, subject
, icon
, theme
e flash
podem ser atualizadas no momento.
As notificações fixadas não estão na fila, por exemplo, se você definir Config.Queue
como 5
e tiver 2
notificações fixadas, receberá um máximo de 7
notificações mostradas a qualquer momento.
Se você estiver usando ESX
, poderá obter bulletin
para substituir as notificações editando as funções apropriadas em 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
boletim Copyright (c) 2021 Mobius1 Este programa é um software livre: você pode redistribuí -lo e/ou modificá -lo nos termos da licença pública geral da GNU, conforme publicado pela Free Software Foundation, versão 3 da licença ou (por sua opção) qualquer versão posterior. Este programa é distribuído na esperança de que seja útil, mas sem garantia; sem a garantia implícita de comercialização ou aptidão para uma finalidade específica. Veja a licença pública geral da GNU para obter mais detalhes. Você deveria ter recebido uma cópia da licença pública geral da GNU junto com este programa. |