猫史档案馆


【box3代码】击杀排行榜代码

用户:egg鸡蛋蛋egg鸡蛋蛋查看:9 回复:6 评论:9 创建时间:2021-12-18T20:28:14


===============================防喵=================================

首先

我们需要白嫖一段喆喵的排行榜代码

// 当玩家进入游戏时
world.onPlayerJoin(({ entity }) => {
    // 设置刚进入游戏的玩家持有金币(coin)数量为0
    entity.player.coin = 0
    // 当玩家按下按键时,触发交互
    entity.player.onPress(({ button }) => {
        if (button === Box3ButtonType.ACTION0) {
            entity.player.dialog({
                type: Box3DialogType.TEXT,
                title: "金币排行榜",
                content: dialogContent(),
            })
        }
    })
});

// 找到世界中的"AT M"机器模型
const atm = world.querySelector(`#A喵`)
// 设置AT M机器可互动
atm.enableInteract = true
// 设置AT M机器互动距离为5
atm.interactRadius = 5;

// 监听世界中的互动事件
world.onInteract(({ entity, targetEntity }) => {
    // 判断被"互动"的实体,
    if (targetEntity.id === "A喵") {
        entity.player.coin = entity.player.coin + 1;
        world.say(`${entity.player.name}获得了1金币!`);
    }
})

// 对话框内容
function dialogContent() {
    // 首先获取当前世界中的所有玩家
    const allPlayerEntities = world.querySelectorAll('player');
    // 然后将所有的玩家进行排序,排序的规则是按照玩家持有的金币数量降序
    const sortedPlayerEntities = allPlayerEntities.sort((a, b)=>  b.player.coin - a.player.coin);
    
    
    // 接下来,我们将在排行榜上以: xxx 有 yyy 个金币 的格式展示,并且每一条信息换一行显示!

        // 首先声明一个content字符串,一会用来保存每一个玩家的信息
        let content = "";
    // 在这里需要做一个循环遍历,将刚才得到的有序的玩家数组遍历一遍
    for(const entity of sortedPlayerEntities ) {
        // 在遍历的过程中,每一次遍历,我们拿到当前的实体(entity),
        // 将实体上的玩家名字(player.name)以及玩家金币数量(player.coin)拼接成排行榜上的一行信息
        // 这样就得到: xxx 有 yyy 个金币 的格式啦
        // 我们在这个文字的末尾加一个\n, 这样我们就能实现换行的效果
        // 紧接着,再把这行信息加上content,这样做是为了把每一个玩家的排行榜信息拼接起来,保存到content中
        content = content + `${entity.player.name}有${entity.player.coin}个金币\n`
    }
    // 最后,把得到的完整的带有玩家名称和金币数量,并且会换行的排行榜数据(content)返回出去
    return content
}

好的我们白嫖完了

没了

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

怎么可能

怎么可能水帖子

 

然后我们需要亿点击杀人后增加分数的代码

持续手撸

 
/* 受到伤害时,向玩家发送私信,提示战斗信息 */
world.onTakeDamage(({ entity, attacker, damage}) => {
    if (!entity.isPlayer) return;
    const attackerName = attacker.isPlayer ? attacker.player.name : attacker.id;
    entity.player.directMessage(`当前hp值${entity.hp}/${entity.maxHp}: 你受到了 ${damage} 点伤害`);
});
world.onDie(({ entity, attacker }) => {
    if (attacker) {
        world.say(attacker.player.name + ' 击杀 ' + entity.player.name)
        entity.player.coin = entity.player.coin + 1;
    }
    if(tai = 0){
        sleep(100).then(()=>{
            entity.player.forceRespawn();
        })
    }
    else if(tai = 1){
        sleep(10000).then(()=>{
            entity.player.forceRespawn();
        })
    }
});
          

fei了

 

最后

把这两段奇怪的代码合起来

// 当玩家进入游戏时
world.onPlayerJoin(({ entity }) => {
    // 设置刚进入游戏的玩家持有金币(coin)数量为0
    entity.player.coin = 0
    // 当玩家按下按键时,触发交互
    entity.player.onPress(({ button }) => {
        if (button === Box3ButtonType.ACTION0) {
            entity.player.dialog({
                type: Box3DialogType.TEXT,
                title: "金币排行榜",
                content: dialogContent(),
            })
        }
    })
});

// 找到世界中的"AT M"机器模型
const atm = world.querySelector(`#A喵`)
// 设置AT M机器可互动
atm.enableInteract = true
// 设置AT M机器互动距离为5
atm.interactRadius = 5;

// 监听世界中的互动事件
world.onInteract(({ entity, targetEntity }) => {
    // 判断被"互动"的实体,
    if (targetEntity.id === "A喵") {
        entity.player.coin = entity.player.coin + 1;
        world.say(`${entity.player.name}获得了1金币!`);
    }
})

// 对话框内容
function dialogContent() {
    // 首先获取当前世界中的所有玩家
    const allPlayerEntities = world.querySelectorAll('player');
    // 然后将所有的玩家进行排序,排序的规则是按照玩家持有的金币数量降序
    const sortedPlayerEntities = allPlayerEntities.sort((a, b)=>  b.player.coin - a.player.coin);
    
    
    // 接下来,我们将在排行榜上以: xxx 有 yyy 个金币 的格式展示,并且每一条信息换一行显示!

        // 首先声明一个content字符串,一会用来保存每一个玩家的信息
        let content = "";
    // 在这里需要做一个循环遍历,将刚才得到的有序的玩家数组遍历一遍
    for(const entity of sortedPlayerEntities ) {
        // 在遍历的过程中,每一次遍历,我们拿到当前的实体(entity),
        // 将实体上的玩家名字(player.name)以及玩家金币数量(player.coin)拼接成排行榜上的一行信息
        // 这样就得到: xxx 有 yyy 个金币 的格式啦
        // 我们在这个文字的末尾加一个\n, 这样我们就能实现换行的效果
        // 紧接着,再把这行信息加上content,这样做是为了把每一个玩家的排行榜信息拼接起来,保存到content中
        content = content + `${entity.player.name}有${entity.player.coin}个金币\n`
    }
    // 最后,把得到的完整的带有玩家名称和金币数量,并且会换行的排行榜数据(content)返回出去
    return content
}
/* 受到伤害时,向玩家发送私信,提示战斗信息 */
world.onTakeDamage(({ entity, attacker, damage}) => {
    if (!entity.isPlayer) return;
    const attackerName = attacker.isPlayer ? attacker.player.name : attacker.id;
    entity.player.directMessage(`当前hp值${entity.hp}/${entity.maxHp}: 你受到了 ${damage} 点伤害`);
});
world.onDie(({ entity, attacker }) => {
    if (attacker) {
        world.say(attacker.player.name + ' 击杀 ' + entity.player.name)
    entity.player.coin = entity.player.coin + 1;
    }
    if(tai = 0){
        sleep(100).then(()=>{
            entity.player.forceRespawn();
        })
    }
    else if(tai = 1){
        sleep(10000).then(()=>{
            entity.player.forceRespawn();
        })
    }
});

 

是不是十分的完美؏؏☝ᖗ乛◡乛ᖘ☝؏؏

emotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_doge

 


回复

上一页1 页 / 共 1下一页
egg鸡蛋蛋egg鸡蛋蛋

点赞0


评论


egg鸡蛋蛋egg鸡蛋蛋

emotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_dogeemotion_doge

‘海’帖子

点赞0


评论


TVMOOCTVMOOC

可以教一下跑酷排行榜怎么写吗?

点赞0


评论


指令者指令者

DDDDDD

点赞0


评论


无极玄天无极玄天

顶顶顶

点赞0


评论


呵呵0486呵呵0486

虽然但是 最后那个判断喵复活时间的为啥是=不是==()

点赞0


评论