121

回帖

8124

金币

4403

积分

积分
4403
发表于 2025-9-5 01:44:56 | 显示全部楼层 |阅读模式

马上注册,下载996引擎,与更多游戏开发者交流。

您需要 登录 才可以下载或查看,没有账号?注册

×

是真正的背包神器,而不是自定义装备
这里只提供思路,稍微会lua脚本的应该都看的懂 理论上TXT也可以用 这里只提供思路
由于后端入包触发是高频触发 而且还不好检查物品 是否出包 . 这里直接利用前端背包变动 命中背包神器

前端代码


SL:RegisterLUAEvent(LUA_EVENT_BAG_ITEM_CHANGE, "背包数据变化", function(data)   --table — {opera = 操作类型 ( 0:初始化 1:增加 2:删除 3:改变), operID = 物品数据(table)}
    if data and data.opera ~= 0 then
        local operID = data.operID and data.operID[1]
        if operID then
            local item = operID.item
            if item then
                local Index = item.Index
                if _C.weaponitems[Index] then -- 这里检查这个物品是否背包神器
                    SL:SendLuaNetMsg(9999, 7012, 0, 0, SL:JsonEncode({Index}, true))
                end
            end
        end
    end
end)


-- 后端代码

npc.config = {
    [10108] = function (play, bool) -- 上古玉玺
        local buffid = 10108
        local isbuff = hasbuff(play, buffid)
        if bool then
            if not isbuff then
                _P.addbuff(play, buffid)
            end
        else
            if isbuff then
                _P.delbuff(play, buffid)
            end
        end
    end,

... 添加更多背包神器 不过这玩意儿占背包格子 一般不建议搞太多 ,搞太多种的最好用自定义装备
}

function npc.main(play, data)
    local idx = data[1]
    local callback = npc.config[idx]
    if not callback then
        return
    end

    local bool = checkitems(play, idx .. "#1", 0, 1)
    callback(play, bool)
end





回复

使用道具 举报