Jelajahi Sumber

修复多个人同时完成或死亡时提示多次的 Bug

LTCatt 6 tahun lalu
induk
melakukan
404e5eaa60

+ 4 - 3
data/mini/functions/main/player_failed.mcfunction

@@ -1,10 +1,10 @@
 # 玩家失败时由玩家自己触发
 
-# 失败提示与计数
+# 计数
 tag @s remove mini_running
 scoreboard players set $t_alive mem 0
 execute as @a[tag=mini_running] run scoreboard players add $t_alive mem 1
-tellraw @a [{"selector": "@s","color":"red"}," 已失败! 剩余 ",{"score": {"name": "$t_alive","objective": "mem"}}," 人!"]
+execute if score $t_alive mem matches 1.. run tellraw @a [{"selector": "@s","color":"red"}," 已失败! 剩余 ",{"score": {"name": "$t_alive","objective": "mem"}}," 人!"]
 
 # 给存活的玩家加分
 scoreboard players add @a[tag=mini_running] mini_score 1
@@ -14,4 +14,5 @@ gamemode spectator @s
 spectate @r[tag=mini_running]
 
 # 如果只有一个玩家没有失败,则游戏结束
-execute if score $t_alive mem matches ..1 run function mini:main/game_end
+# 这里设置成等于就不会触发多次 game_end 了
+execute if score $t_alive mem matches 1 run function mini:main/game_end

+ 4 - 3
data/mini/functions/main/player_finished.mcfunction

@@ -1,10 +1,10 @@
 # 玩家成功时由玩家自己触发
 
-# 成功提示与计数
+# 计数
 tag @s remove mini_running
 scoreboard players set $t_finish mem 0
 execute as @a[tag=!mini_running] run scoreboard players add $t_finish mem 1
-tellraw @a [{"selector": "@s","color":"green"}," 已成功! 第 ",{"score": {"name": "$t_finish","objective": "mem"}}," 名!"]
+execute if score $t_alive mem matches ..3 run tellraw @a [{"selector": "@s","color":"green"}," 已成功! 第 ",{"score": {"name": "$t_finish","objective": "mem"}}," 名!"]
 
 # 给已完成的玩家加分
 scoreboard players add @a[tag=!mini_running] mini_score 1
@@ -14,4 +14,5 @@ gamemode spectator @s
 spectate @r[tag=mini_running]
 
 # 如果有三个玩家成功,则游戏结束
-execute if score $t_finish mem matches 3.. run function mini:main/game_end
+# 这里设置成等于就不会触发多次 game_end 了
+execute if score $t_finish mem matches 3 run function mini:main/game_end

+ 1 - 1
data/mini/functions/parkour/spectator_range.mcfunction

@@ -1,2 +1,2 @@
 # 观察者限制飞行范围
-execute as @a[gamemode=spectator] unless entity @s[x=1001,y=11,z=1001,dx=11,dz=17,dy=24] run tp @s 1007 24 1005
+execute as @a[gamemode=spectator] unless entity @s[x=1001,y=11,z=1001,dx=11,dy=17,dz=24] run tp @s 1007 24 1005