猫史档案馆


重启代码(大佬勿喷)

用户:功名功名查看: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(`你没权限`)

 

            }         }         })

 

代码非常简单,很容易理解,所以没注释,不懂的地方在帖子下回复()


回复

上一页1 页 / 共 1下一页
145a145a

有更好的方法:让服务器崩溃(我是认真的)

点赞0


评论


功名功名

那个太训了,就一个while(1){}

点赞0


评论


搬码喵搬码喵

屑()

点赞0


评论


睿策升华重生版睿策升华重生版

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


评论


盗码师盗码师

功名就是屑哎

点赞0


评论