更好的組隊系統(tǒng)(指令)
版本適用:1.19.51 條件限制:玩家人數(shù)在3-11人 優(yōu)點:滿足組隊需求且組隊隊伍顏色隨機,兩隊人數(shù)相對平均,比較公平 局限性:只能分配兩個隊伍,不能主動選隊伍顏色 原理:只改變分隊順序(半窮舉),無判斷兩隊人數(shù)部分 PS:指令太多了不方便打我就簡寫吧,想看完整的詳看視頻 新版指令格式: execute if score a/b/c(虛擬實體) num (計分板名稱) matches 分數(shù)范圍 run 簡化版指令(太懶) team(隊伍)num(人數(shù)) a (組隊玩家人數(shù)) b(游戲玩家總數(shù))c(組隊隊伍顏色) ---------------------------------------------------------------------- sc ob add team dummy(循環(huán)紅控) sc ob add num dummy tag @e[hasitem=..,tag=!zd] add zd1 exe if entity @e[tag=zd1] run playsound.. exe as @e[tag=zd1] run tellraw ..selector:tag=zd1,"text":"加入組隊! exe as @e[tag=zd] run replaceitem .. air 1 0 exe as @e[tag=zd1] run tag @s add zd2 exe as @e[tag=zd2] run tag @s remove zd1 sc pl set @e[tag=zd2] num 1 sc pl set a num 0 sc pl op a num += @e[tag=zd2] num exe if score a num matches 0..3 run tag @e[tag=zd2] add zd exe if score a num matches 4 run tellraw .. selector:tag=zd2,tag=!zd,"text":"被移除 了組隊“ exe if score a num matches 4 run tag @e[tag=zd2,tag=!zd] remove zd2 exe as @e[tag=zd] run titleraw @a ..."text""組隊玩家”selector:tag=zd tag @e[tag=!zd] add fzd sc pl set @e num 1 sc pl set b num 0 sc pl op b num += @e num sc pl ran c num 1 2 ---------------------------------------------------------------------- sc pl set @e team 0 setblock *** air(坐標是上邊那一部分紅石塊位置) exe if score b num matches 3..4 run tag @e[tag=zd] remove zd exe if score b num matches 3..4 run tag @e[tag=!zd] add fzd exe if score b num matches 3..4 run tellraw .."text":"人數(shù)不足4人,取消所有人組隊“ exe if score b num matches 3..4 run sc pl set @e[tag=fzd,c=2,scores={team=0}] ?team 1 exe if score b num matches 3..4 run sc pl set @e[tag=fzd,c=2,scores={team=0}] ?team 2 exe if sc b num ma 5..11 run exe if sc c num ma 1 run sc pl set @e[tag=zd,scores ={team=0}] team 1 exe if sc b num ma 5..11 run exe if sc c num ma 1 run sc pl set @e[c=3,tag=fzd, scores={team=0}] team 2 exe..run exe if sc a num ma 0..2 run sc pl set @e[tag=fzd,scores={team=0}] team 1 exe if sc b num ma 7..11 run exe if sc c num ma 1 run sc pl set @e[tag=fzd,c=1, scores={team=0}] team 2 exe if sc b num ma 9..11 run exe if sc c num ma 1 run sc pl set @e[tag=fzd,c=1, scores={team=0}] team 2 exe if sc b num ma 11..11 run exe if sc c num ma 1 run sc pl set @e[tag=fzd,c=1, scores={team=0}] team 2 exe..run sc pl set @e[c=4,tag=fzd,scores={team=0}] team 1 exe if sc b num ma 5..11 run exe if sc c num ma 2 run sc pl set @e[tag=zd,scores ={team=0}] team 2 exe if sc b num ma 5..11 run exe if sc c num ma 2 run sc pl set @e[c=3,tag=fzd, scores={team=0}] team 1 exe..run exe if sc a num ma 0..2 run sc pl set @e[tag=fzd,scores={team=0}] team 2 exe if sc b num ma 7..11 run exe if sc c num ma 2 run sc pl set @e[tag=fzd,c=1, scores={team=0}] team 1 exe if sc b num ma 9..11 run exe if sc c num ma 2 run sc pl set @e[tag=fzd,c=1, scores={team=0}] team 1 exe if sc b num ma 11..11 run exe if sc c num ma 2 run sc pl set @e[tag=fzd,c=1, scores={team=0}] team 1 exe..run sc pl set @e[c=4,tag=fzd,scores={team=0}] team 2 playsound random.levelup .. spreadplayers *** @e[scores={team=1}] spreadplayers *** @e[scores={team=2}] sc ob remove num tag @e remove zd zd1 zd2 fzd