[MCBE]1CB可自定義商店系統(tǒng)

指令樓:
創(chuàng)建積分版:
/scoreboard objectives add 數(shù)據(jù) dummy
/scoreboard objectives add 數(shù)量 dummy
/scoreboard objectives add 購買 dummy
/scoreboard objectives add 金幣 dummy
/scoreboard objectives add cd dummy
創(chuàng)建虛擬計(jì)分項(xiàng):
/scoreboard players set 十 數(shù)據(jù) 10
視角檢測:
execute @a[ry=30,rym=0,rx=-20,tag=u] ~~~ scoreboard players set @s cd 1
execute @a[ry=60,rym=30,rx=-20,tag=u] ~~~ scoreboard players set @s cd 2
execute @a[ry=90,rym=60,rx=-20,tag=u] ~~~ scoreboard players set @s cd 3
execute @a[ry=30,rym=0,rx=-5,rxm=-10,tag=u] ~~~ scoreboard players set @s cd 4
execute @a[ry=60,rym=30,rx=-5,rxm=-10,tag=u] ~~~ scoreboard players set @s cd 5
execute @a[ry=90,rym=60,rx=-5,rxm=-10,tag=u] ~~~ scoreboard players set @s cd 6
execute @a[ry=30,rym=0,rx=10,rxm=0,tag=u] ~~~ scoreboard players set @s cd 7
execute @a[ry=60,rym=30,rx=10,rxm=0,tag=u] ~~~ scoreboard players set @s cd 8
execute @a[ry=90,rym=60,rx=10,rxm=0,tag=u] ~~~ scoreboard players set @s cd 9
execute @a[ry=30,rym=0,rx=20,rxm=10,tag=u] ~~~ scoreboard players set @s cd 10
execute @a[ry=60,rym=30,rx=20,rxm=10,tag=u] ~~~ scoreboard players set @s cd 11
execute @a[ry=90,rym=60,rx=20,rxm=10,tag=u] ~~~ scoreboard players set @s cd 12
scoreboard players add @a 數(shù)據(jù) 0
scoreboard players add @a 購買 0
scoreboard players set @a[tag=!u,scores={數(shù)據(jù)=!0,購買=0}] 數(shù)據(jù) 0
玩家購買檢測:
testfor @a[scores={購買=1..},tag=!u]
setblock ~1 ~ ~ chain_command_block 5(上面這個(gè)是有條件連鎖保持開啟)
空一格
setblock ~-1 ~ ~ air
execute @a[tag=!u,scores={購買=1..}] ~ ~ ~ detect ~ ~-1 ~ quartz_block 0 execute @s ~ ~ ~ detect ~ ~-2 ~ command_block -1 execute @s ~ ~ ~ detect ~ ~-3 ~ barrel -1 tellraw @s {"rawtext":[{"text":"§a》》§7物品信息對(duì)接成功"}]}
execute @a[tag=!u,scores={購買=1..}] ~ ~ ~ detect ~ ~-1 ~ quartz_block 0 execute @s ~ ~ ~ detect ~ ~-2 ~ command_block -1 execute @s ~ ~ ~ detect ~ ~-3 ~ barrel -1 playsound random.enderchestopen @s ~~~ 1 1.38
execute @a[tag=!u,scores={購買=1..}] ~ ~ ~ detect ~ ~-1 ~ quartz_block 0 execute @s ~ ~ ~ detect ~ ~-2 ~ command_block -1 execute @s ~ ~ ~ detect ~ ~-3 ~ barrel -1 tp @s ~~~ 45 -10
execute @a[tag=!u,scores={購買=1..}] ~ ~ ~ detect ~ ~-1 ~ quartz_block 0 execute @s ~ ~ ~ detect ~ ~-2 ~ command_block -1 execute @s ~ ~ ~ detect ~ ~-3 ~ barrel -1 tag @s add u
tellraw @a[tag=!u,scores={購買=1..}] {"rawtext":[{"text":"§4》》§7請(qǐng)站在石英塊上"}]}
scoreboard players set @a[tag=!u,scores={購買=1..}] 購買 0
顯示:
execute @a[scores={cd=1},tag=u] ~~~ titleraw @s actionbar {"rawtext":[
{"text":"§b -§7Purchase menu§b-
§5-§7購買菜單§5-
§2?§a購買數(shù)量:§6"},
{"score":{"name":"@s","objective":"數(shù)據(jù)"}},
{"text":"
§r□------------------□§l§7
§6[§g1§6]§7 [2] [3]
[4] [5] [6]
[7] [8] [9]
[清除] [0] [確認(rèn)]
§r§c[§4Shop§c]§r--------------□"}]}
execute @a[scores={cd=2},tag=u] ~~~ titleraw @s actionbar {"rawtext":[
{"text":"§b -§7Purchase menu§b-
§5-§7購買菜單§5-
§2?§a購買數(shù)量:§6"},
{"score":{"name":"@s","objective":"數(shù)據(jù)"}},
{"text":"
§r□------------------□§l§7
[1] §6[§g2§6]§7 [3]
[4] [5] [6]
[7] [8] [9]
[清除] [0] [確認(rèn)]
§r§c[§4Shop§c]§r--------------□"}]}
execute @a[scores={cd=3},tag=u] ~~~ titleraw @s actionbar {"rawtext":[
{"text":"§b -§7Purchase menu§b-
§5-§7購買菜單§5-
§2?§a購買數(shù)量:§6"},
{"score":{"name":"@s","objective":"數(shù)據(jù)"}},
{"text":"
§r□------------------□§l§7
[1] [2] §6[§g3§6]§7
[4] [5] [6]
[7] [8] [9]
[清除] [0] [確認(rèn)]
§r§c[§4Shop§c]§r--------------□"}]}
execute @a[scores={cd=4},tag=u] ~~~ titleraw @s actionbar {"rawtext":[
{"text":"§b -§7Purchase menu§b-
§5-§7購買菜單§5-
§2?§a購買數(shù)量:§6"},
{"score":{"name":"@s","objective":"數(shù)據(jù)"}},
{"text":"
§r□------------------□§l§7
[1] [2] [3]
§6[§g4§6]§7 [5] [6]
[7] [8] [9]
[清除] [0] [確認(rèn)]
§r§c[§4Shop§c]§r--------------□"}]}
execute @a[scores={cd=5},tag=u] ~~~ titleraw @s actionbar {"rawtext":[
{"text":"§b -§7Purchase menu§b-
§5-§7購買菜單§5-
§2?§a購買數(shù)量:§6"},
{"score":{"name":"@s","objective":"數(shù)據(jù)"}},
{"text":"
§r□------------------□§l§7
[1] [2] [3]
[4] §6[§g5§6]§7 [6]
[7] [8] [9]
[清除] [0] [確認(rèn)]
§r§c[§4Shop§c]§r--------------□"}]}
execute @a[scores={cd=6},tag=u] ~~~ titleraw @s actionbar {"rawtext":[
{"text":"§b -§7Purchase menu§b-
§5-§7購買菜單§5-
§2?§a購買數(shù)量:§6"},
{"score":{"name":"@s","objective":"數(shù)據(jù)"}},
{"text":"
§r□------------------□§l§7
[1] [2] [3]
[4] [5] §6[§g6§6]§7
[7] [8] [9]
[清除] [0] [確認(rèn)]
§r§c[§4Shop§c]§r--------------□"}]}
execute @a[scores={cd=7},tag=u] ~~~ titleraw @s actionbar {"rawtext":[
{"text":"§b -§7Purchase menu§b-
§5-§7購買菜單§5-
§2?§a購買數(shù)量:§6"},
{"score":{"name":"@s","objective":"數(shù)據(jù)"}},
{"text":"
§r□------------------□§l§7
[1] [2] [3]
[4] [5] [6]
§6[§g7§6]§7 [8] [9]
[清除] [0] [確認(rèn)]
§r§c[§4Shop§c]§r--------------□"}]}
execute @a[scores={cd=8},tag=u] ~~~ titleraw @s actionbar {"rawtext":[
{"text":"§b -§7Purchase menu§b-
§5-§7購買菜單§5-
§2?§a購買數(shù)量:§6"},
{"score":{"name":"@s","objective":"數(shù)據(jù)"}},
{"text":"
§r□------------------□§l§7
[1] [2] [3]
[4] [5] [6]
[7] §6[§g8§6]§7 [9]
[清除] [0] [確認(rèn)]
§r§c[§4Shop§c]§r--------------□"}]}
execute @a[scores={cd=9},tag=u] ~~~ titleraw @s actionbar {"rawtext":[
{"text":"§b -§7Purchase menu§b-
§5-§7購買菜單§5-
§2?§a購買數(shù)量:§6"},
{"score":{"name":"@s","objective":"數(shù)據(jù)"}},
{"text":"
§r□------------------□§l§7
[1] [2] [3]
[4] [5] [6]
[7] [8] §6[§g9§6]§7
[清除] [0] [確認(rèn)]
§r§c[§4Shop§c]§r--------------□"}]}
execute @a[scores={cd=10},tag=u] ~~~ titleraw @s actionbar {"rawtext":[
{"text":"§b -§7Purchase menu§b-
§5-§7購買菜單§5-
§2?§a購買數(shù)量:§6"},
{"score":{"name":"@s","objective":"數(shù)據(jù)"}},
{"text":"
§r□------------------□§l§7
[1] [2] [3]
[4] [5] [6]
[7] [8] [9]
§6[§g清除§6]§7 [0] [確認(rèn)]
§r§c[§4Shop§c]§r--------------□"}]}
execute @a[scores={cd=11},tag=u] ~~~ titleraw @s actionbar {"rawtext":[
{"text":"§b -§7Purchase menu§b-
§5-§7購買菜單§5-
§2?§a購買數(shù)量:§6"},
{"score":{"name":"@s","objective":"數(shù)據(jù)"}},
{"text":"
§r□------------------□§l§7
[1] [2] [3]
[4] [5] [6]
[7] [8] [9]
[清除] §6[§g0§6]§7 [確認(rèn)]
§r§c[§4Shop§c]§r--------------□"}]}
execute @a[scores={cd=12},tag=u] ~~~ titleraw @s actionbar {"rawtext":[
{"text":"§b -§7Purchase menu§b-
§5-§7購買菜單§5-
§2?§a購買數(shù)量:§6"},
{"score":{"name":"@s","objective":"數(shù)據(jù)"}},
{"text":"
§r□------------------□§l§7
[1] [2] [3]
[4] [5] [6]
[7] [8] [9]
[清除] [0] §6[§g確認(rèn)§6]
§r§c[§4Shop§c]§r--------------□"}]}
檢測購買玩家是否在商品位置:
execute @a[tag=u,scores={購買=1..}] ~ ~ ~ tag @s add 檢測
execute @a[tag=u,scores={購買=1..}] ~ ~ ~ detect ~ ~-1 ~ quartz_block 0 execute @s ~ ~ ~ detect ~ ~-2 ~ command_block -1 execute @s ~ ~ ~ detect ~ ~-3 ~ barrel -1 tag @s remove 檢測
execute @a[tag=u,scores={購買=1..}] ~ ~ ~ detect ~~-1~ wooden_button -1 execute @s ~~~ detect ~ ~-2 ~ quartz_block 0 execute @s ~ ~ ~ detect ~ ~-3 ~ command_block -1 execute @s ~ ~ ~ detect ~ ~-4 ~ barrel -1 tag @s remove 檢測
execute @a[tag=檢測,tag=u,scores={購買=1..}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§4》》§7物品信息對(duì)接錯(cuò)誤,已重置"}]}
scoreboard players set @a[tag=檢測] 購買 0
tag @a[tag=檢測] remove u
tag @a remove 檢測
一些計(jì)算:
execute @a[tag=u,scores={購買=1..,cd=1..11,cd=!10}] ~~~ detect ~~-1~ wooden_button -1 scoreboard players operation @s 數(shù)據(jù) *= 十 數(shù)據(jù)
execute @a[tag=u,scores={購買=1..,cd=1..9}] ~~~ detect ~~-1~ wooden_button -1 scoreboard players operation @s 數(shù)據(jù) += @s cd
execute @a[tag=u,scores={購買=1..,cd=10}] ~~~ detect ~~-1~ wooden_button -1 scoreboard players operation @s 數(shù)據(jù) /= 十 數(shù)據(jù)
execute @a[tag=u,scores={購買=1..,cd=12}] ~~~ detect ~~-1~ wooden_button -1 scoreboard players operation @s 購買 *= @s 數(shù)據(jù)
execute @a[scores={購買=1..,cd=12}] ~~~ detect ~~-1~ wooden_button -1 scoreboard players operation @s 金幣 -= @s 購買
execute @a[tag=u,scores={購買=1..,cd=12,金幣=..-1}] ~~~ detect ~~-1~ wooden_button -1 playsound block.false_permissions @s ~~~ 0.8 2
tellraw @a[scores={金幣=..-1},tag=u] {"rawtext":[{"text":"§4》》§7購買失敗,金幣不足"}]}
execute @a[tag=u,scores={購買=1..,cd=12,金幣=..-1}] ~~~ detect ~~-1~ wooden_button -1 playsound random.glass @s ~ ~ ~ 0.7 1.8
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 clone ~~-4~ ~~-4~ ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 setblock ~~~ air 0 destroy
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 kill @e[type=item,c=1,r=1.5,name=木桶]
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 structure save shop1 ~~~ ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 structure load shop1 ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 structure save shop2 ~~~ ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 structure load shop2 ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 structure save shop4 ~~~ ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 structure load shop4 ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 structure save shop8 ~~~ ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 structure load shop8 ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 structure save shop16 ~~~ ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 structure load shop16 ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 structure save shop32 ~~~ ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 structure load shop32 ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 structure save shop64 ~~~ ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 kill @e[r=1,type=item]
execute @a[scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 scoreboard players operation @s 數(shù)量 = @s 數(shù)據(jù)
execute @a[scores={購買=1..,cd=12,金幣=0..,數(shù)據(jù)=64..}] ~~~ detect ~~-1~ wooden_button -1 structure load shop64 ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..,數(shù)據(jù)=64..}] ~~~ detect ~~-1~ wooden_button -1 scoreboard players remove @s 數(shù)據(jù) 64
execute @a[scores={購買=1..,cd=12,金幣=0..,數(shù)據(jù)=32..}] ~~~ detect ~~-1~ wooden_button -1 structure load shop32 ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..,數(shù)據(jù)=32..}] ~~~ detect ~~-1~ wooden_button -1 scoreboard players remove @s 數(shù)據(jù) 32
execute @a[scores={購買=1..,cd=12,金幣=0..,數(shù)據(jù)=16..}] ~~~ detect ~~-1~ wooden_button -1 structure load shop16 ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..,數(shù)據(jù)=16..}] ~~~ detect ~~-1~ wooden_button -1 scoreboard players remove @s 數(shù)據(jù) 16
execute @a[scores={購買=1..,cd=12,金幣=0..,數(shù)據(jù)=8..}] ~~~ detect ~~-1~ wooden_button -1 structure load shop8 ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..,數(shù)據(jù)=8..}] ~~~ detect ~~-1~ wooden_button -1 scoreboard players remove @s 數(shù)據(jù) 8
execute @a[scores={購買=1..,cd=12,金幣=0..,數(shù)據(jù)=4..}] ~~~ detect ~~-1~ wooden_button -1 structure load shop4 ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..,數(shù)據(jù)=4..}] ~~~ detect ~~-1~ wooden_button -1 scoreboard players remove @s 數(shù)據(jù) 4
execute @a[scores={購買=1..,cd=12,金幣=0..,數(shù)據(jù)=2..}] ~~~ detect ~~-1~ wooden_button -1 structure load shop2 ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..,數(shù)據(jù)=2..}] ~~~ detect ~~-1~ wooden_button -1 scoreboard players remove @s 數(shù)據(jù) 2
execute @a[scores={購買=1..,cd=12,金幣=0..,數(shù)據(jù)=1..}] ~~~ detect ~~-1~ wooden_button -1 structure load shop1 ~~~
execute @a[scores={購買=1..,cd=12,金幣=0..,數(shù)據(jù)=1..}] ~~~ detect ~~-1~ wooden_button -1 scoreboard players remove @s 數(shù)據(jù) 1
execute @a[tag=u,scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 scoreboard players operation @s 數(shù)據(jù) = @s 數(shù)量
execute @a[tag=u,scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 tellraw @s {"rawtext":[{"text":"§a》》§7購買成功,共花費(fèi)§b"},
{"score":{"name":"@s","objective":"購買"}},
{"text":"元§g購買了§6"},{"score":{"name":"@s","objective":"數(shù)據(jù)"}},{"text":"§g件§l§e"},{"selector":"@e[c=1,type=item,r=1.5]"}]}
execute @a[tag=u,scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 playsound random.orb @s ~ ~ ~ 1 0.32
execute @a[tag=u,scores={購買=1..,cd=12,金幣=0..}] ~~~ detect ~~-1~ wooden_button -1 playsound random.chestopen @s ~~~ 0.75 0.85
execute @a[scores={購買=1..,cd=12,金幣=..-1}] ~~~ detect ~~-1~ wooden_button -1 scoreboard players operation @s 金幣 += @s 購買
execute @a[tag=u,scores={購買=1..,cd=12}] ~~~ detect ~~-1~ wooden_button -1 tag @s remove u
execute @a[scores={購買=1..,cd=12}] ~~~ detect ~~-1~ wooden_button -1 scoreboard players set @s 購買 0
execute @a[tag=u,scores={購買=1..,cd=1..}] ~~~ detect ~~-1~ wooden_button -1 tp @s ~~-1~
沒有了.....