player_finished.mcfunction 987 B

12345678910111213141516171819202122
  1. # 玩家成功时由玩家自己触发
  2. # 计数
  3. tag @s remove mini_running
  4. execute store result score $alive mem if entity @a[tag=mini_running,tag=!watcher]
  5. execute store result score $t_finish mem if entity @a[tag=!mini_running,tag=!watcher]
  6. # 显示提示
  7. execute if entity @s[tag=!rejoining] if score $t_finish mem matches ..3 run tellraw @a [{"selector": "@s","color":"green"}," 已成功! 第 ",{"score": {"name": "$t_finish","objective": "mem"}}," 名!"]
  8. execute as @a at @s run function lib:sounds/error
  9. # 给已完成的玩家加分
  10. scoreboard players add @a[tag=!mini_running] mini_score 1
  11. # 进入旁观
  12. gamemode spectator @s
  13. spectate @r[tag=mini_running]
  14. # 如果有三个玩家成功,或只有一个玩家未成功,则游戏结束
  15. # 这里设置成等于就不会触发多次 game_end 了
  16. execute if score $t_finish mem matches 3 run function mini:main/game_end
  17. execute if score $t_finish mem matches ..2 if score $alive mem matches 1 run function mini:main/game_end