try_start_gameparty.mcfunction 1.5 KB

12345678910111213141516171819
  1. # 尝试开始派对模式
  2. # 计算玩家数量
  3. execute store result score $count mem if entity @a[tag=lobby_ready]
  4. # 判断玩家数量过少
  5. execute if score $count mem matches ..2 as @a at @s run function lib:sounds/error
  6. execute if score $count mem matches ..2 run tellraw @a ["",{"text": ">> ","color":"red","bold": true},"需要至少 3 人准备以开始游戏, ",{"text":"当前仅有 ","color":"red"},{"score": {"name": "$count","objective": "mem"},"color":"red"},{"text": " 人","color":"red"}]
  7. execute if score $count mem matches ..2 run scoreboard players set $countdown mem 0
  8. # 提示未准备
  9. execute if score $countdown mem matches 10 run tellraw @a[tag=!lobby_ready] [{"text":"","color":"red"},{"text":">> ","bold": true},"你现在还没有准备, 可以丢出快捷栏最后一格的物品准备!"]
  10. # 判断玩家数量过多
  11. execute if score $count mem matches 9.. if score $countdown mem matches 15 run tellraw @a [{"text":"","color":"gold"},{"text":">> ","bold": true},"游戏最多支持 8 人, 当前已有 ",{"score": { "name": "$count","objective": "mem"}}, " 人, 将随机抽取 8 人开始游戏!"]
  12. execute if score $count mem matches 9.. if score $countdown mem matches 1 run tellraw @a [{"text":"","color":"gold"},{"text":">> ","bold": true},"游戏最多支持 8 人, 当前已有 ",{"score": { "name": "$count","objective": "mem"}}, " 人, 将随机抽取 8 人开始游戏!"]
  13. # 开始游戏
  14. execute if score $countdown mem matches 1 run function ltw:state/0/start_gameparty