用户:
功名查看:2 回复:5 评论:2 创建时间:2022-09-14T08:32:08
运用我昨天发的帖子的代码,就可以制作出一个很逊的重启代码(互动类型)
const npc71 = world.querySelector('#控制终端') npc71.enableInteract = true npc71.interactRadius = 5 npc71.interactHint = npc71.id npc71.interactColor = new Box3RGBAColor(1,1,1)npc71.onInteract(async ({ entity }) => { const result = await entity.player.dialog({ type: Box3DialogType.SELECT, title: npc71.id, content: `请选择`, options: ['重启服务器'] }) if (result) { if (result.index == 0 && (entity.player.name == '功名爱吃南瓜' || entity.player.name == "MoranTao")) { entity.player.directMessage(`正在加载...`) await sleep(3000) entity.player.directMessage(`加载完毕`) world.say(`${entity.player.name}开启了重启`) world.say('3') await sleep(1000) world.say('2') await sleep(1000) world.say('1') await sleep(1000) world.say('重启!') for (e of world.querySelectorAll('player')) { e.player.kick() } }else { entity.player.directMessage(`你没权限`)
} } })
代码非常简单,很容易理解,所以没注释,不懂的地方在帖子下回复()
睿策升华重生版const npc71 = world.querySelector('#控制终端')
npc71.enableInteract = true
npc71.interactRadius = 5
npc71.interactHint = npc71.id
npc71.interactColor = new Box3RGBAColor(1,1,1)
npc71.onInteract(async ({ entity }) => {
const result = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: npc71.id,
content: `请选择`,
options: ['重启服务器']
})
if (result) {
if (result.index == 0 && (entity.player.name == '杨睿12503死神' || entity.player.name == "MoranTao")) { entity.player.directMessage(`正在加载...`)
await sleep(3000)
entity.player.directMessage(`加载完毕`)
world.say(`${entity.player.name}开启了重启`)
world.say('3')
await sleep(1000)
world.say('2')
await sleep(1000)
world.say('1')
await sleep(1000)
world.say('重启!')
for (e of world.querySelectorAll('player')) {
e.player.kick() }
}else {
entity.player.directMessage(`你没权限`)
} } })
点赞0
评论