用户:
海底有微光查看:0 回复:1 评论:0 创建时间:2024-08-15T17:34:50
const admin = ['--','--','--',]//在这输入管喵名字
world.onChat(async({entity,message}) => {
if(admin.includes(entity.player.name)&&message[0] == '$') {
world.say('<~'+message)
try{
world.say('~>' + await eval(message.slice(1)))
}catch(err){
world.say('~>'+err)
}
}
})
在这基础上,在玩家聊天框输入$+飞行代码+玩家名字使玩家获得飞行
const admin = ['--', '--', '--']; // 在这输入管喵名字
const flightEnabledPlayers = new Set(); // 用于跟踪获得飞行权限的玩家
world.onChat(async ({ entity, message }) => {
// 检查是否是管喵并且消息以'$'开头
if (admin.includes(entity.player.name) && message[0] === '$') {
world.say('<~' + message);
try {
// 分割消息以获取指令和目标玩家名称
const args = message.slice(1).trim().split(' ');
const command = args[0];
const targetPlayerName = args[1];
// 检查指令是否是'fly'
if (command === 'fly' && targetPlayerName) {
const targetPlayer = world.getPlayer(targetPlayerName);
if (targetPlayer) {
// 为目标玩家添加飞行权限
flightEnabledPlayers.add(targetPlayerName);
world.say(`~> 为${targetPlayerName}启用飞行`);
} else {
world.say(`~> 玩家${targetPlayerName}不存在`);
}
} else {
// 其他命令的执行
world.say('~>' + await eval(message.slice(1)));
}
} catch (err) {
world.say('~>' + err);
}
}
});
// 在游戏的逻辑中检查玩家是否可以飞行
world.onPlayerUpdate((player) => {
if (flightEnabledPlayers.has(player.name)) {
// 给予飞行能力
player.setFlying(true);
} else {
// 取消飞行能力
player.setFlying(false);
}
});点赞0
评论