Fivem的可自定義通知。模仿本機GTAV通知,但允許更多自定義
css覆蓋添加到ui/css/custom.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 | 不 | 通知的標題(僅高級) | ||
subject | string | 不 | 通知的主題 /字幕(僅高級) | ||
icon | string | 不 | 要使用的圖片(僅高級) |
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 Dimages目錄,然後將自定義代碼和文件名添加到Config.Pictures表中的config.lua中,
將my_custom_icon_image.jpg上傳到ui/images目錄,然後使用MY_CUSTOM_ICON_CODE (no Space!)作為密鑰。
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
公告支持以下格式:
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 該程序是免費的軟件:您可以根據自由軟件基金會發布的GNU通用公共許可證的條款對其進行重新分配和/或修改它,該版本是該許可證的版本3,或(按您的選項)任何以後的版本。 該程序的分佈是希望它將有用的,但沒有任何保修;即使沒有對特定目的的適銷性或適合性的隱含保證。有關更多詳細信息,請參見GNU通用公共許可證。 您應該已經收到了GNU通用公共許可證的副本以及此計劃。 |