搜索
开启左侧

汉化

[复制链接]
赴爱 发表于 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的交互。
回复

使用道具 举报

文明发言,和谐互动
文明发言,和谐互动
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|FiveM技术教程分享 ( 冀ICP备2021005225号-1 ) |网站地图

GMT+8, 2025-4-19 07:02 , Processed in 0.076252 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

© 2001-2013 ELITE论坛【技术无价-分享快乐】

快速回复 返回顶部 返回列表