player_changed.mcfunction 503 B

123456789
  1. # 初始化玩家数量
  2. execute unless score $player_count mem matches -2147483648..2147483647 store result score $player_count mem if entity @a
  3. # 计算玩家数量
  4. execute store result score $player_count_now mem if entity @a
  5. # 比较玩家数量
  6. execute if score $player_count_now mem < $player_count mem run function ltw:main/player_leave
  7. # 重置玩家数量
  8. execute unless score $player_count_now mem = $player_count mem run scoreboard players operation $player_count mem = $player_count_now mem