Notifications personnalisables pour FIVEM. Imite les notifications GTAV natives, mais permet plus de personnalisation
css
à 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 )
Ce sont des méthodes scolaristes pour envoyer une notification thématique. Ils prennent les mêmes paramètres / table que la méthode 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 ( ... )
Toutes les méthodes peuvent être déclenchées à la fois du client et du serveur:
-- standard
TriggerClientEvent ( ' bulletin:send ' , source , ... )
-- advanced
TriggerClientEvent ( ' bulletin:sendAdvanced ' , source , ... )
Ceux-ci sont passés sous forme de paramètres individuels ou dans un tableau:
paramot | taper | défaut | options | facultatif | description |
---|---|---|---|---|---|
message | string | NON | Le message à envoyer. Peut être une chaîne ou un HTML valide | ||
timeout | integer | 5000 | OUI | La durée de ms pour afficher la notification | |
position | string | "bottomleft" | "bottomleft" , "topleft" , "topright" , "bottomright" , "bottom" , "top" | OUI | La possibilité de la notification |
progress | boolean | false | true , false | OUI | S'il faut afficher la progression du délai d'expiration de la notification |
theme | string | "default" | "default" , "success" , "info" , "warning" , "error" | OUI | Le thème de la notification |
exitAnim | string | "fadeOut" | Voir animate.css pour les options | OUI | L'animation utilisée pour cacher la notification |
flash | boolean | false | OUI | Fait clignoter la notification | |
title | string | NON | Le titre de la notification (avancé uniquement) | ||
subject | string | NON | Le sujet / sous-titre de la notification (avancé uniquement) | ||
icon | string | NON | L'image à utiliser (avancé uniquement) |
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
}
Pour ajouter votre propre image personnalisée, téléchargez une image jpg
64x64
au répertoire ui/images
et ajoutez le code et le nom de fichier personnalisés à la table Config.Pictures
dans config.lua
,
Téléchargez my_custom_icon_image.jpg
dans le répertoire ui/images
et utilisez MY_CUSTOM_ICON_CODE
(pas d'espaces!) Comme clé.
Config . Pictures = {
...
MY_CUSTOM_ICON_CODE = " my_custom_icon_image.jpg " -- Add this
}
Utilisez ensuite le code personnalisé dans l'appel de notification:
exports . bulletin : SendAdvanced ( " Message " , " Title " , " Subject " , " MY_CUSTOM_ICON_CODE " )
Vous pouvez activer un son de notification en téléchargeant un fichier son personnalisé dans le répertoire ui/audio
et en modifiant la configuration pour l'utiliser:
Config . SoundFile = ' my_notification_sound.mp3 '
Config . SoundVolume = 0.4
Fichiers audio valides: .mp3
, .ogg
, .wav
Le bulletin prend en charge le formatage suivant:
n = new line
~ r ~ = Red
~ b ~ = Blue
~ g ~ = Green
~ y ~ = Yellow
~ p ~ = Purple
~ o ~ = Orange
~ u ~ = Black
~ w ~ = White
~ h ~ = Bold Text
Vous pouvez également utiliser HTML pour les couleurs:
exports . bulletin : Send ( " <span class='r'>I am red</span> and <span class='y'>I am yellow</span> " )
ou n'importe quel html que vous aimez
exports . bulletin : Send ( " <h1>Some Title</h1><p class='paragraph'>Some text</p><footer>Some footer text</footer> " )
Afin d'envoyer une notification épinglée, vous devrez stocker le pin_id
de la notification afin que vous puissiez le défaire plus tard.
local pinID = exports . bulletin : SendPinned ({
type = ' advanced ' -- or 'standard'
message = ' This is pinned! '
})
Ensuite, pour un défaut, il suffit de passer la valeur stockée à la méthode Unpin()
:
exports . bulletin : Unpin ( pinID )
La méthode Unpin()
accepte également un table
d'ID PIN:
exports . bulletin : Unpin ({ pinned1 , pinned2 , pinned3 })
ou omettez le param pour un tout:
exports . bulletin : Unpin ()
Vous pouvez également mettre à jour le contenu d'une notification épinglée:
-- 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
})
Seules les options de message
, title
, subject
, icon
, theme
et flash
peuvent être mises à jour pour le moment.
Les notifications épinglées ne sont pas en file d'attente, par exemple, si vous définissez Config.Queue
sur 5
et que vous avez 2
notifications épinglées, vous obtiendrez un maximum de 7
notifications indiquées à tout moment.
Si vous utilisez ESX
, vous pouvez obtenir bulletin
pour remplacer les notifications en modifiant les fonctions appropriées dans 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
bulletin Copyright (C) 2021 MOBIUS1 Ce programme est un logiciel gratuit: vous pouvez le redistribuer et / ou le modifier en vertu des termes de la licence publique générale GNU publiée par la Free Software Foundation, soit la version 3 de la licence, ou (à votre option) toute version ultérieure. Ce programme est distribué dans l'espoir qu'il sera utile, mais sans aucune garantie; Sans même la garantie implicite de qualité marchande ou d'adéquation à un usage particulier. Voir la licence publique générale GNU pour plus de détails. Vous devriez avoir reçu une copie de la licence publique générale GNU avec ce programme. |