猫史档案馆


举报&意见箱代码(hhhhhhh)

用户:我是昵称哦我是昵称哦查看:2 回复:4 评论:2 创建时间:2022-07-22T19:09:13


global.Z = ['你的名字~~~~~~~~~~']
db.sql`CREATE TABLE IF NOT EXISTS "advice"(
    "title" TEXT NOT NULL
)`
world.querySelectorAll('.liuyan').forEach(async (e) => {
    e.enableInteract = true
    e.interactHint = '举报&意见箱'
    e.interactRadius = 100;
    e.onInteract(async ({ entity }) => {
        const result_1 = await entity.player.dialog({
            type: Box3DialogType.SELECT,
            title: "举报&意见箱",
            content: `欢迎举报&意见`,
            options: ['留言栏', '查看留言内容'],
        });
        //如果玩家点击了屏幕其他区域,取消对话框
        if (!result_1 || result_1 === null) {
            return;
        }
        //判断玩家选了什么选项
        switch (result_1.index) {
            case 0:
                const rows = await db.sql`SELECT * FROM "advice"`;
                let title = '';
                for (let i in rows) {
                    title += rows[i].title + '\n';
                }
                const 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: '发布成功,谢谢你的建议',
                        })
                    } else {
                        entity.player.dialog({
                            type: Box3DialogType.TEXT,
                            title: '举报&意见箱',
                            content: '字数不能超过20个字哦~',
                        })
                    }
                }
                break
            case 1:
                if (Z.includes(entity.player.name)) {
                    const rows = await db.sql`SELECT * FROM "advice"`;
                    let title = '';
                    for (let i in rows) {
                        title += rows[i].title + '\n';
                    }
                    const result = await entity.player.dialog({
                        type: Box3DialogType.TEXT,
                        title: '举报&意见箱',
                        content: title,
                    })
                } else {
                    entity.player.dialog({
                        type: 'text',
                        content: '无法查看此内容'
                    })
                }
            default:
        }
    })
})


回复

上一页1 页 / 共 1下一页
我是昵称哦我是昵称哦

imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%BF%BB%E7%99%BD%E7%9C%BC.gif"alt="emotion_编程猫_翻白眼"width="518"height="518"

点赞0


评论


我是昵称哦我是昵称哦

imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E6%90%93%E5%A4%B4.gif"alt="emotion_编程猫_搓头"

点赞0


评论


我是昵称哦我是昵称哦

imgsrc="https://static.codemao.cn/emotion/thunder_monkey/%E6%91%87%E6%A4%85%E5%AD%90240.gif"alt="emotion_雷电猴_摇椅子"

点赞0


评论


_function__function_

做个诚实的孩子

这个代码我之前公布过

笑死了不会真有人抄袭还不换变量名()

就改了content里的内容,你真棒!

……

点赞0


评论