Fivemのカスタマイズ可能な通知。ネイティブGTAV通知を模倣しますが、さらにカスタマイズを可能にします
ui/css/custom.css
に独自のcss
オーバーライドを追加して、外観をカスタマイズします~r~
、 ~b~
、 ~h~
など)をサポートします 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 )
これらは、テーマ通知を送信するための速記の方法です。彼らは、 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 ( ... )
すべてのメソッドは、クライアントとサーバーの両方からトリガーできます。
-- standard
TriggerClientEvent ( ' bulletin:send ' , source , ... )
-- advanced
TriggerClientEvent ( ' bulletin:sendAdvanced ' , source , ... )
これらは、個々のパラマまたはテーブル内で渡されます。
パラメーション | タイプ | デフォルト | オプション | オプション | 説明 |
---|---|---|---|---|---|
message | string | いいえ | 送信するメッセージ。文字列または有効なHTMLにすることができます | ||
timeout | integer | 5000 | はい | 通知を表示するためのms の期間 | |
position | string | "bottomleft" | "bottomleft" 、 "topleft" 、 "topright" 、 "bottomright" 、 "bottom" 、 "top" | はい | 通知の掲載 |
progress | boolean | false | true 、 false | はい | 通知タイムアウトの進捗を表示するかどうか |
theme | string | "default" | "default" 、 "success" 、 "info" 、 "warning" 、 "error" | はい | 通知のテーマ |
exitAnim | string | "fadeOut" | オプションについては、 animate.css を参照してください | はい | 通知を隠すために使用されるアニメーション |
flash | boolean | false | はい | 通知を点滅させます | |
title | string | いいえ | 通知のタイトル(Advancedのみ) | ||
subject | string | いいえ | 通知の件名 /サブタイトル(Advancedのみ) | ||
icon | string | いいえ | 使用する写真(Advancedのみ) |
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
}
独自のカスタム画像を追加するには、 64x64
jpg
画像をui/images
ディレクトリにアップロードし、 config.lua
のConfig.Pictures
テーブルにカスタムコードとファイル名を追加します。
my_custom_icon_image.jpg
ui/images
ディレクトリにアップロードし、 MY_CUSTOM_ICON_CODE
(スペースなし!)をキーとして使用します。
Config . Pictures = {
...
MY_CUSTOM_ICON_CODE = " my_custom_icon_image.jpg " -- Add this
}
次に、通知通話でカスタムコードを使用します。
exports . bulletin : SendAdvanced ( " Message " , " Title " , " Subject " , " MY_CUSTOM_ICON_CODE " )
ui/audio
ディレクトリにカスタムサウンドファイルをアップロードし、構成を編集して使用することにより、通知サウンドを有効にすることができます。
Config . SoundFile = ' my_notification_sound.mp3 '
Config . SoundVolume = 0.4
有効なオーディオファイル: .mp3
、 .ogg
、 .wav
Bulletinは次のフォーマットをサポートしています。
n = new line
~ r ~ = Red
~ b ~ = Blue
~ g ~ = Green
~ y ~ = Yellow
~ p ~ = Purple
~ o ~ = Orange
~ u ~ = Black
~ w ~ = White
~ h ~ = Bold Text
色にHTMLを使用することもできます。
exports . bulletin : Send ( " <span class='r'>I am red</span> and <span class='y'>I am yellow</span> " )
またはあなたが好きなhtml
exports . bulletin : Send ( " <h1>Some Title</h1><p class='paragraph'>Some text</p><footer>Some footer text</footer> " )
ピン留め通知を送信するには、通知のpin_id
保存して、後でそれを実行できるようにする必要があります。
local pinID = exports . bulletin : SendPinned ({
type = ' advanced ' -- or 'standard'
message = ' This is pinned! '
})
次に、編集するには、保存された値をUnpin()
メソッドに渡すだけです。
exports . bulletin : Unpin ( pinID )
Unpin()
メソッドは、ピンIDのtable
も受け入れます。
exports . bulletin : Unpin ({ pinned1 , pinned2 , pinned3 })
または、すべてを解除するためにパラメージを省略します。
exports . bulletin : Unpin ()
ピン留め通知のコンテンツを更新することもできます。
-- 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
})
現時点では、 message
、 title
、 subject
、 icon
、 theme
、 flash
オプションのみを更新できます。
ピン留めされた通知はキューに入らないため、たとえば、 Config.Queue
5
に設定し、 2
ピン留め通知がある場合、いつでも表示される7
の通知の最大を取得します。
ESX
使用している場合は、 es_extended/client/functions.lua
で適切な関数を編集することにより、 bulletin
を取得できます。
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
速報 著作権(c)2021 Mobius1 このプログラムはフリーソフトウェアです。フリーソフトウェアファンデーションの条件、ライセンスのバージョン3、または(オプションで)後のバージョンのいずれかで公開されているように、GNU一般公開ライセンスの条件の下でそれを再配布したり、変更したりできます。 このプログラムは、それが有用であることを期待して配布されますが、保証はありません。商品性や特定の目的に対するフィットネスの暗黙の保証さえありません。詳細については、GNU一般公開ライセンスを参照してください。 このプログラムとともに、GNU一般公開ライセンスのコピーを受け取る必要があります。 |