以下是汉化后的代码及注释:
local Debug = ESX.GetConfig().EnableDebug
---@param type string 通知类型
---@param length number 通知持续时间
---@param message any 消息内容 :D
local function Notify(notificatonType, length, message)
if Debug then
print(('1 %s'):format(tostring(notificatonType))) -- 输出通知类型的值
print(('2 %s'):format(tostring(length))) -- 输出通知持续时间的值
print(('3 %s'):format(message)) -- 输出消息内容
end
if type(notificatonType) ~= "string" then
notificatonType = "info" -- 默认通知类型为 "info"
end
if type(length) ~= "number" then
length = 3000 -- 默认通知持续时间为3000毫秒
end
if Debug then
print(('4 %s'):format(tostring(notificatonType))) -- 输出处理后的通知类型
print(('5 %s'):format(tostring(length))) -- 输出处理后的通知持续时间
print(('6 %s'):format(message)) -- 输出处理后的消息内容
end
SendNuiMessage(json.encode({
type = notificatonType or "info", -- 发送的通知类型
length = length or 3000, -- 发送的通知持续时间
message = message or "ESX-Notify" -- 发送的消息,默认为"ESX-Notify"
}))
end
这段代码适合放在 `client.lua` 中,因为它涉及到客户端的通知显示和与NUI的交互。 |