用户:
TX圆周狸kitten分号查看:1 回复:2 评论:1 创建时间:2023-01-07T17:43:01
我来分享一下我肝了一天的管喵禁言代码
world.onChat(async({ entity, message }) => {
if (message === '变大') {
entity.player.scale = 1//玩家输入'变大'时,设置玩家大小为1
} else {
if (message === '变小') {
entity.player.scale = 0.75//玩家输入'变小'时,设置玩家大小为0.75
} else {
if (message === '禁言') {/*如果玩家输入'禁言'*/
if (entity.player.name === 'TX-圆周狸') {/*判断玩家是不是管喵*/
const asount0 = await entity.player.dialog({
type: Box3DialogType.INPUT,
content: `${entity.player.name},你要禁言谁?`,
title: '系统'
})/*如果是,询问玩家要禁言谁*/
if (asount0) {/*如果玩家没有点×退出*/
try {
let csnm = 'null'
let jydx = 'null'
world.querySelectorAll('player').forEach((x) =>{if (x.player.name == asount0) {csnm = x.player.name;jydx = x}})/*查找输入的玩家*/
if (csnm != 'null') {/*如果玩家存在*/
if (entity === csnm) {/*判断输入的玩家是自己*/
entity.player.dialog({
type: Box3DialogType.TEXT,
content: `自己不能禁言自己`,
title: '系统'
})/*弹出禁言失败的提示*/
} else {
jydx.player.muted = true
world.say(`管喵${entity.player.name}已将${csnm}禁言`)/*如果不是,就禁言输入的玩家*/
}
} else {
entity.player.dialog({
type: Box3DialogType.TEXT,
content: `此玩家不存在`,
title: '系统'
})/*如果玩家不存在,弹出提示*/
}
} catch (err) {
entity.player.dialog({
type: Box3DialogType.TEXT,
content: `${err}`,
title: 'Error'
})/*如果有报错,弹出报错信息*/
}
}
} else {
entity.player.dialog({
type: Box3DialogType.TEXT,
content: `你不是管喵`,
title: '系统'
})/*如果玩家不是管喵,弹出提示*/
}
} else {
if (message === '解除禁言') {/*如果玩家输入'解除禁言'*/
if (entity.player.name === 'TX-圆周狸') {/*如果玩家是管喵*/
const asount1 = await entity.player.dialog({
type: Box3DialogType.INPUT,
content: `${entity.player.name},你要将谁解除禁言?`,
title: '系统'
})/*询问玩家要将谁解除禁言*/
if (asount1) {/*如果玩家没有点×退出*/
try {
let csnm = 'null'
let jydx = 'null'
world.querySelectorAll('player').forEach((x) =>{if (x.player.name == asount1) {csnm = x.player.name;jydx = x}})/*查找输入的玩家*/
if (csnm != 'null') {/*如果输入的玩家存在*/
if (jydx.player.muted === true) {/*如果输入的玩家被禁言了*/
jydx.player.muted = false
world.say(`管喵${entity.player.name}已将${csnm}解除禁言`)/*将输入的玩家解除禁言*/
} else {
entity.player.dialog({
type: Box3DialogType.TEXT,
content: `此玩家没有被禁言`,
title: '系统'
})/*如果输入的玩家没有被禁言,就弹出提示*/
}
} else {
entity.player.dialog({
type: Box3DialogType.TEXT,
content: `此玩家不存在`,
title: '系统'
})/*如果输入的玩家不存在,就弹出提示*/
}
} catch(err) {
entity.player.dialog({
type: Box3DialogType.TEXT,
content: `${err}`,
title: 'Error'
})/*如果报错,弹出报错信息*/
}
}
} else {
entity.player.dialog({
type: Box3DialogType.TEXT,
content: `你不是管喵`,
title: '系统'
})/*如果玩家不是管喵,弹出提示*/
}
}
}
}
}
})
使用方法:把这段代码抄到要用的地图上,然后把所有出现过'TX-圆周狸'的地方改成你的名字,然后输入'变大'、'变小'、'禁言'、'解除禁言'就可以实现对应效果了。