用户:
彩虹字转换器查看:6 回复:5 评论:6 创建时间:2022-06-14T10:04:33
快期末了,我要退游了,这是最后一篇贴子
_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
评论
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
评论