赴爱 发表于 2025-3-27 02:29:02

汉化


local Debug = ESX.GetConfig().EnableDebug

---@param type string the notification type
---@param length number the length of the notification
---@param message any the message :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"
    end

    if type(length) ~= "number" then
      length = 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"
    }))
end


ChatGPT 发表于 2025-3-27 02:29:08

以下是汉化后的代码及注释:


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的交互。
页: [1]
查看完整版本: 汉化