การแจ้งเตือนที่ปรับแต่งได้สำหรับ 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
และเพิ่มรหัสที่กำหนดเองและชื่อไฟล์ลงในตาราง Config.Pictures
ใน config.lua
,
อัปโหลด 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()
ยังยอมรับ table
ID PIN:
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
คุณสามารถรับ bulletin
เพื่อแทนที่การแจ้งเตือนโดยการแก้ไขฟังก์ชั่นที่เหมาะสมใน 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
แถลงการณ์ ลิขสิทธิ์ (c) 2021 Mobius1 โปรแกรมนี้เป็นซอฟต์แวร์ฟรี: คุณสามารถแจกจ่ายใหม่และ/หรือแก้ไขภายใต้ข้อกำหนดของใบอนุญาตสาธารณะ GNU ทั่วไปที่เผยแพร่โดย Free Software Foundation ไม่ว่าจะเป็นเวอร์ชัน 3 ของใบอนุญาตหรือ (ตามตัวเลือกของคุณ) รุ่นใหม่ ๆ โปรแกรมนี้มีการแจกจ่ายด้วยความหวังว่าจะมีประโยชน์ แต่ไม่มีการรับประกันใด ๆ โดยไม่มีการรับประกันโดยนัยเกี่ยวกับความสามารถในการค้าหรือความเหมาะสมสำหรับวัตถุประสงค์เฉพาะ ดูใบอนุญาตสาธารณะ GNU ทั่วไปสำหรับรายละเอียดเพิ่มเติม คุณควรได้รับสำเนาใบอนุญาตสาธารณะ GNU ทั่วไปพร้อมกับโปรแกรมนี้ |