猫史档案馆


谁能告诉我一下 CEOの试炼的留言箱的代码?

用户:彩虹字转换器彩虹字转换器查看:6 回复:5 评论:6 创建时间:2022-06-14T10:04:33


快期末了,我要退游了,这是最后一篇贴子 


回复

上一页1 页 / 共 1下一页
彩虹字转换器彩虹字转换器

 谁能告诉我一下 CEOの试炼的留言箱的代码?

点赞0


评论


_function__function_

global.Z = ['']//作者
global.H = ['']//合作者
db.sql`CREATE TABLE IF NOT EXISTS "advice"(//SQL
    "title" TEXT NOT NULL
)`
world.querySelectorAll('.liuyan').forEach(async (e) => {//标签为“liuyan”
    e.enableInteract = true
    e.interactHint = '留言箱'
    e.interactRadius = 5;
    e.onInteract(async ({ entity }) => {
        c喵t result_1 = await entity.player.dialog({
            type: Box3DialogType.SELECT,
            title: "留言箱",
            content: `欢迎留言`,
            opti喵: ['留言栏', '查看留言内容'],
        });
        //如果玩家点击了屏幕其他区域,取消对话框
        if (!result_1 || result_1 === null) {
            return;
        }
        //判断玩家选了什么选项
        switch (result_1.index) {
            case 0:
                c喵t rows = await db.sql`SELECT * FROM "advice"`;
                let title = '';
                for (let i in rows) {
                    title += rows[i].title + '\n';
                }
                c喵t result = await entity.player.dialog({
                    type: Box3DialogType.INPUT,
                    title: '意见箱',
                    content: '举报&意见(字数<=20字)',
                    placeholder: '输入你想说的话...禁止骂人)',
                })
                if (result != null) {
                    if (result.length <= 20) {
                        db.sql`INSERT INTO "advice" VALUES(${entity.player.name + ':' + result})`;//插入新字段
                        entity.player.dialog({
                            type: Box3DialogType.TEXT,
                            title: '意见箱',
                            content: '发布成功,谢谢你的建议\n作者将会在一周内查看并回复你的留言\n请留意',
                        })
                    } else {
                        entity.player.dialog({
                            type: Box3DialogType.TEXT,
                            title: '意见箱',
                            content: '字数不能超过20个字哦~',
                        })
                    }
                }
                break
            case 1:
                if (Z.includes(entity.player.name) || H.includes(entity.player.name)) {
                    c喵t rows = await db.sql`SELECT * FROM "advice"`;
                    let title = '';
                    for (let i in rows) {
                        title += rows[i].title + '\n';
                    }
                    c喵t result = await entity.player.dialog({
                        type: Box3DialogType.TEXT,
                        title: '意见箱',
                        content: title,
                    })
                } else {
                    entity.player.dialog({
                        type: 'text',
                        content: 'emm,你还没有权限去查看此内容'
                    })
                }
            default:
        }
    })
})

点赞1


评论


_function__function_

加油取个好成绩

CEO等你回来)

点赞0


评论


彩虹字转换器彩虹字转换器

imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"

点赞0


评论


屑怪盗屑怪盗

 保存

点赞0


评论