用户:
萌新大佬查看:8 回复:10 评论:8 创建时间:2022-05-10T10:24:25
直接上代码,看不懂评论区里问。
const VIP_Player=['萌新大佬'];//自己改
world.onChat(({entity,message})=>{
if(!VIP_Player.includes(entity.player.name))return;
if(!message.startsWith('禁足')||!message.startsWith('解禁'))
var other=world.querySelectorAll('player').find((e)=>e.player.name==message.slice(2));
if(!other||other==null){
entity.player.directMessage('此人不存在');
return;
}
if(message.startsWith('禁足')){
if(other.canMove==false){
entity.player.directMessage('此人已禁足');
return;
}
other.player.directMessage('你被禁足了!');
entity.player.directMessage('禁足成功');
other.moveArg={
walkSpeed:other.player.walkSpeed,
walkAcceleration:other.player.walkAcceleration,
runSpeed:other.player.runSpeed,
runAcceleration:other.player.runAcceleration,
crouchSpeed:other.player.crouchSpeed,
crouchAcceleration:other.player.crouchAcceleration,
enableJump:other.player.enableJump,
enableDoubleJump:other.player.enableDoubleJump
};
other.player.walkSpeed=
other.player.walkAcceleration=
other.player.runSpeed=
other.player.runAcceleration=
other.player.crouchSpeed=
other.player.crouchAcceleration=
0;
other.player.enableJump=
other.player.enableDoubleJump=
false;
other.canMove=false;
}else if(message.startsWith('解禁')){
if(other.canMove==true||other.canMove==null){
entity.player.directMessage('此人还未禁足或已被解禁');
return;
}
other.player.directMessage('你被解禁了!');
entity.player.directMessage('解禁成功');
Object.assign(other.player,other.moveArg);
other.canMove=true;
}
})这样好像更简单():
const admin = ['一剑走天下'];
world.onChat(async({ entity , message }) => {
if(admin.includes(entity.player.name)) {
if(message.startsWith('禁足')) {
world.querySelectorAll('player').forEach(async( user ) => {
if(user.player.name == message.slice(2)) {
if(user.player.disableInputDirection == Box3InputDirection.NONE) {
user.player.disableInputDirection = Box3InputDirection.BOTH;
user.player.jumpPower = 0;
entity.player.directMessage(`${user.player.name}已被禁足`);
user.player.directMessage(`你被禁足了!`)
}else {
entity.player.directMessage('此人已被禁足!')
}
}else {
entity.player.directMessage('此人不在地图内!')
}
})
}
if(message.startsWith('解除禁足')) {
world.querySelectorAll('player').forEach(async( user ) => {
if(user.player.name == message.slice(4)) {
if(user.player.disableInputDirection == Box3InputDirection.BOTH) {
user.player.disableInputDirection = Box3InputDirection.NONE;
user.player.jumpPower = 0.96;
entity.player.directMessage(`${user.player.name}已解除禁足`);
user.player.directMessage(`你被解除禁足了!`)
}else {
entity.player.directMessage('此人已被解除禁足!')
}
}else {
entity.player.directMessage('此人不在地图内!')
}
})
}
}
})点赞0
评论
银狐残影const VIP_Player=['萌新大佬'];//自己改
world.onChat(({entity,message})=>{
if(!VIP_Player.includes(entity.player.name))return;
if(!message.startsWith('禁足')||!message.startsWith('解禁'))
var other=world.querySelectorAll('player').find((e)=>e.player.name==message.slice(2));
if(!other||other==null){
entity.player.directMessage('此人不存在');
return;
}
if(message.startsWith('禁足')){
if(other.canMove==false){
entity.player.directMessage('此人已禁足');
return;
}
other.player.directMessage('你被禁足了!');
entity.player.directMessage('禁足成功');
other.moveArg={
walkSpeed:other.player.walkSpeed,
walkAcceleration:other.player.walkAcceleration,
runSpeed:other.player.runSpeed,
runAcceleration:other.player.runAcceleration,
crouchSpeed:other.player.crouchSpeed,
crouchAcceleration:other.player.crouchAcceleration,
enableJump:other.player.enableJump,
enableDoubleJump:other.player.enableDoubleJump
};
other.player.walkSpeed=
other.player.walkAcceleration=
other.player.runSpeed=
other.player.runAcceleration=
other.player.crouchSpeed=
other.player.crouchAcceleration=
0;
other.player.enableJump=
other.player.enableDoubleJump=
false;
other.canMove=false;
}else if(message.startsWith('解禁')){
if(other.canMove==true||other.canMove==null){
entity.player.directMessage('此人还未禁足或已被解禁');
return;
}
other.player.directMessage('你被解禁了!');
entity.player.directMessage('解禁成功');
Object.assign(other.player,other.moveArg);
other.canMove=true;
}
})点赞0
评论
这也不行啊()(
禁足代码:
entity.player.disableInputDirection=Box3InputDirection.BOTH
恢复代码:
entity.player.disableInputDirection=Box3InputDirection.NONE
很简单…………
点赞0
评论