箱子商店系统v2.0

By MCSugar_cane    2017/11/18

哈!你有想过有一天能在原版服务器里创建属于你自己的商店并出售物品吗?也许以前没有这方面的作品(OOC),但现在就有啦~具体实现原理和代码见下文,本系统需要与银行系统同时运行!

代码适用版本为v1.11.2-v1.12

2.0版本于2018\1\31更新


箱子商店系统v2.0箱子商店系统v2.0箱子商店系统v2.0箱子商店系统v2.0

图片就介绍到这里,下面是思路以及代码部分~


目录:

  1. 基础:
  2. 创建与设置
  3. 存货购买与撤销提现
    1. 拓展:
    2. 注意事项
    3. 关于出售物品拓展
    4. OOC
  4. 更新/修复

整体思路:

要实现这个系统难点就在于如何区分不同玩家所创建的不同商店,将创建者与他所创建的商店所匹配。在这里,我利用了流动ID分配,在创建时为每个商店分配不同ID,并且时这个ID值=创建者ID值。这样一来,只需要用玩家ID值-商店ID值的结果来区分其是否为该商店创建者。


代码:

创建与设置:

创建变量:

/scoreboard objectives add createitem dummy /scoreboard objectives add createfacing dummy /scoreboard objectives add whocreate stat.useItem.minecraft.spawn_egg /scoreboard objectives add shopSetting dummy /scoreboard objectives add shopID dummy /scoreboard objectives add isale trigger /scoreboard objectives add items dummy /scoreboard objectives add getShopId dummy /scoreboard objectives add getSale dummy

生成商店蛋:[高频循环]

/scoreboard players set @e[type=Item] createitem 1 {Item:{id:"minecraft:chest",Count:1b,Damage:0s},OnGround:1b} /scoreboard players set @e[type=Item] createitem 2 {Item:{id:"minecraft:sign",Count:1b,Damage:0s},OnGround:1b} execute @e[type=Item,score_createitem_min=1,score_createitem=1] ~ ~ ~ execute @e[score_createitem_min=2,score_createitem=2,r=1,c=1] ~ ~ ~ summon Item ~ ~0.5 ~ {Item:{id:"minecraft:spawn_egg",Count:1b,tag:{EntityTag:{id:"minecraft:bat",CustomName:"CreateShop",NoAI:1,Silent:1b,ActiveEffects:[{Id:14,Duration:9999999,Amplifier:50,Ambient:1}]},HideFlags:127,ench:[{id:34,lvl:10}],display:{Name:"创建商店",Lore:["www.Ganxiaozhe.com"]}}},Motion:[0.0,0.4,0.0]} execute @e[type=Item,score_createitem_min=1,score_createitem=1] ~ ~ ~ execute @e[score_createitem_min=2,score_createitem=2,r=1,c=1] ~ ~ ~ playsound minecraft:entity.armorstand.break voice @a[r=8] execute @e[type=Item,score_createitem_min=1,score_createitem=1] ~ ~ ~ execute @e[score_createitem_min=2,score_createitem=2,r=1,c=1] ~ ~ ~ particle totem ~ ~1 ~ 0.2 0.6 0.2 0.2 80 execute @e[type=Item,score_createitem_min=1,score_createitem=1] ~ ~ ~ execute @e[score_createitem_min=2,score_createitem=2,r=1,c=1] ~ ~ ~ kill @e[type=Item,score_createitem_min=1,r=1]

检测玩家朝向以放置正确位置商店:[高频循环]

/scoreboard players set @a[score_whocreate_min=1,rym=-135,ry=-45] createfacing 1 /scoreboard players set @a[score_whocreate_min=1,rym=135,ry=-135] createfacing 2 /scoreboard players set @a[score_whocreate_min=1,rym=46,ry=135] createfacing 3 /scoreboard players set @a[score_whocreate_min=1,rym=-45,ry=45] createfacing 4

放置商店:[高频循环]

/execute @a[score_whocreate_min=1,score_createfacing_min=1,score_createfacing=1] ~ ~ ~ execute @e[name=CreateShop,c=1] ~ ~ ~ setblock ~ ~ ~ chest 4 masked {Lock:"Locked by ganxiaozhe"} /execute @a[score_whocreate_min=1,score_createfacing_min=1,score_createfacing=1] ~ ~ ~ execute @e[name=CreateShop,c=1] ~ ~ ~ setblock ~-1 ~ ~ wall_sign 4 /execute @a[score_whocreate_min=1,score_createfacing_min=2,score_createfacing=2] ~ ~ ~ execute @e[name=CreateShop,c=1] ~ ~ ~ setblock ~ ~ ~ chest 3 masked {Lock:"Locked by ganxiaozhe"} /execute @a[score_whocreate_min=1,score_createfacing_min=2,score_createfacing=2] ~ ~ ~ execute @e[name=CreateShop,c=1] ~ ~ ~ setblock ~ ~ ~1 wall_sign 3 /execute @a[score_whocreate_min=1,score_createfacing_min=3,score_createfacing=3] ~ ~ ~ execute @e[name=CreateShop,c=1] ~ ~ ~ setblock ~ ~ ~ chest 5 masked {Lock:"Locked by ganxiaozhe"} /execute @a[score_whocreate_min=1,score_createfacing_min=3,score_createfacing=3] ~ ~ ~ execute @e[name=CreateShop,c=1] ~ ~ ~ setblock ~1 ~ ~ wall_sign 5 /execute @a[score_whocreate_min=1,score_createfacing_min=4,score_createfacing=4] ~ ~ ~ execute @e[name=CreateShop,c=1] ~ ~ ~ setblock ~ ~ ~ chest 1 masked {Lock:"Locked by ganxiaozhe"} /execute @a[score_whocreate_min=1,score_createfacing_min=4,score_createfacing=4] ~ ~ ~ execute @e[name=CreateShop,c=1] ~ ~ ~ setblock ~ ~ ~-1 wall_sign 1 /execute @a[score_whocreate_min=1] ~ ~ ~ execute @e[name=CreateShop,c=1] ~ ~ ~ /summon Villager ~ ~ ~ {CustomName:"cShop",NoAI:1b,Silent:1b,Offers:{Recipes:[]},ActiveEffects:[{Id:14,Duration:9999999,Amplifier:50,Ambient:1}]} /execute @a[score_whocreate_min=1] ~ ~ ~ scoreboard players set @e[name=cShop,c=1] shopSetting 1 /execute @e[type=bat,name=CreateShop] ~ ~ ~ /scoreboard players tag @a[score_whocreate_min=1,r=7] add wcreate /kill @e[type=bat,name=CreateShop] /scoreboard players reset @a[score_whocreate_min=1] whocreate

商店设置部分:[高频循环]

/execute @e[name=cShop,score_shopSetting_min=1,score_shopSetting=1] ~ ~ ~ tp @p[tag=wcreate] @e[name=cShop,c=1] /execute @e[name=cShop,score_shopSetting_min=1,score_shopSetting=1] ~ ~ ~ tellraw @p[tag=wcreate] [{"text":"[甘小蔗] ","color":"dark_green","bold":"true"},{"selector":"@p[tag=wcreate]","color":"gold","bold":"true"},{"text":" 请丢弃(一个)你要出售的物品以进行设置(在过程中请勿移动)","color":"green","bold":true}] /scoreboard players set @e[name=cShop,score_shopSetting_min=1,score_shopSetting=1] shopSetting 2 /execute @e[name=cShop,score_shopSetting_min=2,score_shopSetting=2] ~ ~ ~ scoreboard players set @e[type=Item,r=1] createitem -1 {Item:{id:"minecraft:iron_ingot",Count:1b,Damage:0s}} /execute @e[name=cShop,score_shopSetting_min=2,score_shopSetting=2] ~ ~ ~ scoreboard players set @e[type=Item,r=1] createitem -2 {Item:{id:"minecraft:reeds",Count:1b,Damage:0s}} /execute @e[type=Item,score_createitem_min=-1,score_createitem=-1] ~ ~ ~ scoreboard players tag @e[name=cShop,c=1] add s_iron_ingot /execute @e[type=Item,score_createitem_min=-2,score_createitem=-2] ~ ~ ~ scoreboard players tag @e[name=cShop,c=1] add s_reeds /scoreboard players tag @e[type=Item,score_createitem=-1,tag=!ishow] add ishow /execute @e[type=cShop,score_shopSetting_min=2,score_shopSetting=2] ~ ~ ~ teleport @e[type=Item,score_createitem=-1,c=1] ~ ~0.5 ~ /entitydata @e[type=Item,score_createitem=-1] {PickupDelay:10000,Age:-23333,NoGravity:1,Item:{tag:{Ganxiaozhe:1}}} /execute @e[name=cShop,score_shopSetting_min=2,score_shopSetting=2] ~ ~ ~ scoreboard players set @p[tag=wcreate] isale -1 /execute @e[type=Item,score_createitem=-1] ~ ~ ~ scoreboard players set @e[name=cShop,score_shopSetting_min=2,score_shopSetting=2,r=1] shopSetting 3 /execute @e[name=cShop,score_shopSetting_min=3,score_shopSetting=3] ~ ~ ~ scoreboard players enable @p[tag=wcreate] isale /execute @e[name=cShop,score_shopSetting_min=3,score_shopSetting=3] ~ ~ ~ tellraw @p[tag=wcreate] [{"text":"[甘小蔗] ","color":"dark_green","bold":"true"},{"selector":"@p[tag=wcreate]","color":"gold","bold":"true"},{"text":" 输入","color":"green","bold":true},{"text":" /trigger isale set 价钱 ","color":"red","bold":true},{"text":"以设置物品单价(价位0-100000)","color":"green","bold":true}] /scoreboard players tag @a[tag=wcreate,score_isale_min=0,score_isale=100000] add setsale /execute @a[tag=setsale] ~ ~ ~ scoreboard players set @e[name=cShop,score_shopSetting_min=3,score_shopSetting=3,c=1] shopSetting 4 /execute @a[tag=setsale] ~ ~ ~ scoreboard players operation @e[name=cShop,score_shopSetting_min=4,score_shopSetting=4,c=1] isale = @p[tag=setsale] isale /execute @e[name=cShop,score_shopSetting_min=4,score_shopSetting=4] ~ ~ ~ scoreboard players operation @p[tag=setsale] shopID = @e[name=cShop,c=1,score_shopID_min=0] shopID /execute @a[tag=setsale] ~ ~ ~ /tellraw @p[tag=wcreate] [{"text":"[甘小蔗] ","color":"dark_green","bold":"true"},{"selector":"@p[tag=setsale]","color":"gold","bold":"true"},{"text":" 您的商店已经设置完毕","color":"green","bold":true}] /scoreboard players tag @a[tag=setsale] remove wcreate /scoreboard players tag @a[tag=setsale] add createdShop /scoreboard players tag @a[tag=createdShop] remove setsale /execute @e[name=cShop,score_shopSetting_min=4,score_shopSetting=4] ~ ~ ~ teleport @e[score_createitem=-1,c=1] ~ ~0.5 ~ /scoreboard players add @e[name=cShop,score_shopSetting_min=4,score_shopSetting=4] items 1 /scoreboard players set @e[name=cShop,score_shopSetting_min=4,score_shopSetting=4] shopSetting -1

shopID分配部分:[高频循环](创建载体:summon armor_stand ~ ~ ~ {CustomName:"shopIDStats"}

/scoreboard players add @e[name=cShop,score_shopSetting_min=1,score_shopSetting=2] shopID 0 /execute @e[name=cShop,score_shopID_min=0,score_shopID=0] ~ ~ ~ scoreboard players add @e[type=armor_stand,name=shopIDStats] shopID 1 /execute @e[name=cShop,score_shopID_min=0,score_shopID=0] ~ ~ ~ scoreboard players operation @e[name=cShop,score_shopID_min=0,score_shopID=0,r=0,c=1] shopID = @e[type=armor_stand,name=shopIDStats] shopID

告示牌信息显示部分:[高频循环]

信息获取: /execute @e[name=cShop,score_shopSetting=-1] ~ ~ ~ scoreboard players operation @p getShopId = @e[name=cShop,r=0,c=1] shopID /execute @e[name=cShop,score_shopSetting=-1] ~ ~ ~ scoreboard players operation @p getSale = @e[name=cShop,r=0,c=1] isale /execute @e[name=cShop,score_shopSetting=-1] ~ ~ ~ scoreboard players operation @p items = @e[name=cShop,r=0,c=1] items 信息显示: execute @e[name=cShop,score_shopSetting=-1] ~ ~ ~ blockdata ~-1 ~ ~ {Text1:"{\"text\":\"ShopID:\",\"bold\":\"true\",\"color\":\"dark_red\",\"extra\":[\"\"],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"\"}}",Text2:"{\"score\":{\"name\":\"@p\",\"objective\":\"getShopId\"},\"color\":\"red\",\"bold\":\"true\",\"extra\":[\"\"],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"\"}}",Text3:"{\"score\":{\"name\":\"@p\",\"objective\":\"getSale\"},\"color\":\"black\",\"bold\":\"true\",\"extra\":[\"¥/每份\"],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"say More on Ganxiaozhe.com\"}}",Text4:"{\"score\":{\"name\":\"@p\",\"objective\":\"items\"},\"color\":\"black\",\"bold\":\"true\",\"extra\":[\"份/剩余\"],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"\"}}"} execute @e[name=cShop,score_shopSetting=-1] ~ ~ ~ blockdata ~1 ~ ~ {Text1:"{\"text\":\"ShopID:\",\"bold\":\"true\",\"color\":\"dark_red\",\"extra\":[\"\"],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"\"}}",Text2:"{\"score\":{\"name\":\"@p\",\"objective\":\"getShopId\"},\"color\":\"red\",\"bold\":\"true\",\"extra\":[\"\"],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"\"}}",Text3:"{\"score\":{\"name\":\"@p\",\"objective\":\"getSale\"},\"color\":\"black\",\"bold\":\"true\",\"extra\":[\"¥/每份\"],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"say More on Ganxiaozhe.com\"}}",Text4:"{\"score\":{\"name\":\"@p\",\"objective\":\"items\"},\"color\":\"black\",\"bold\":\"true\",\"extra\":[\"份/剩余\"],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"\"}}"} execute @e[name=cShop,score_shopSetting=-1] ~ ~ ~ blockdata ~ ~ ~-1 {Text1:"{\"text\":\"ShopID:\",\"bold\":\"true\",\"color\":\"dark_red\",\"extra\":[\"\"],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"\"}}",Text2:"{\"score\":{\"name\":\"@p\",\"objective\":\"getShopId\"},\"color\":\"red\",\"bold\":\"true\",\"extra\":[\"\"],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"\"}}",Text3:"{\"score\":{\"name\":\"@p\",\"objective\":\"getSale\"},\"color\":\"black\",\"bold\":\"true\",\"extra\":[\"¥/每份\"],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"say More on Ganxiaozhe.com\"}}",Text4:"{\"score\":{\"name\":\"@p\",\"objective\":\"items\"},\"color\":\"black\",\"bold\":\"true\",\"extra\":[\"份/剩余\"],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"\"}}"} execute @e[name=cShop,score_shopSetting=-1] ~ ~ ~ blockdata ~ ~ ~1 {Text1:"{\"text\":\"ShopID:\",\"bold\":\"true\",\"color\":\"dark_red\",\"extra\":[\"\"],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"\"}}",Text2:"{\"score\":{\"name\":\"@p\",\"objective\":\"getShopId\"},\"color\":\"red\",\"bold\":\"true\",\"extra\":[\"\"],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"\"}}",Text3:"{\"score\":{\"name\":\"@p\",\"objective\":\"getSale\"},\"color\":\"black\",\"bold\":\"true\",\"extra\":[\"¥/每份\"],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"say More on Ganxiaozhe.com\"}}",Text4:"{\"score\":{\"name\":\"@p\",\"objective\":\"items\"},\"color\":\"black\",\"bold\":\"true\",\"extra\":[\"份/剩余\"],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"\"}}"}

使玩家只能有1个商店:[高频循环]

clear @a[tag=createdShop] spawn_egg 0 64 {display:{Name:"创建商店"}}



存货购买与撤销提现:

创建变量:

/scoreboard objectives add savei dummy /scoreboard objectives add iclick stat.talkedToVillager /scoreboard objectives add IDtemp dummy /scoreboard objectives add ctemp dummy /scoreboard objectives add ibuy trigger /scoreboard objectives add delshop trigger /scoreboard objectives add btemp dummy /scoreboard objectives add btimer dummy /scoreboard objectives add bpd dummy /scoreboard objectives add selling dummy /scoreboard objectives add savecash dummy /scoreboard objectives add cash dummy 银行系统现金 /scoreboard objectives add iget trigger

商店存货部分:[高频循环]

/execute @e[name=cShop,score_shopSetting=-1] ~ ~ ~ scoreboard players set @e[type=Item,r=1,tag=!ishow] savei 1 {Item:{id:"minecraft:iron_ingot",Count:1b,Damage:0s}} /execute @e[name=cShop,score_shopSetting=-1] ~ ~ ~ scoreboard players set @e[type=Item,r=1,tag=!ishow] savei 2 {Item:{id:"minecraft:reeds",Count:1b,Damage:0s}} /execute @e[type=Item,score_savei_min=1] ~ ~ ~ scoreboard players operation @e[type=Item,c=1] savei += @e[type=Item,c=1,score_createitem=-1] createitem /execute @e[type=Item,score_savei_min=0,score_savei=0] ~ ~ ~ scoreboard players add @e[name=cShop,score_shopSetting=-1,c=1] items 1 /execute @e[type=Item,score_savei_min=0,score_savei=0] ~ ~ ~ tellraw @p[tag=createdShop,r=6] [{"text":"[甘小蔗] ","color":"dark_green","bold":"true"},{"selector":"@p[tag=createdShop]","color":"gold","bold":"true"},{"text":" 成功增加存库\u00a7a+1","color":"green","bold":true}] /kill @e[type=Item,score_savei_min=0,score_savei=0]


商店出售部分:[高频循环]

检测右键:

/execute @e[name=cShop,score_shopSetting=-1] ~ ~ ~ scoreboard players tag @a[r=6,score_iclick_min=1] add whoclick /scoreboard players set @a[score_iclick_min=1] iclick 0

检测右键者身份:

/execute @a[tag=whoclick] ~ ~ ~ scoreboard players operation @p[r=0] IDtemp = @p[r=0] shopID /execute @a[tag=whoclick] ~ ~ ~ scoreboard players operation @p[r=0] IDtemp -= @e[name=cShop,score_shopSetting=-1,c=1] shopID /scoreboard players tag @a[tag=whoclick,score_IDtemp_min=1] add noper /scoreboard players tag @a[tag=whoclick,score_IDtemp=-1] add noper /scoreboard players tag @a[tag=whoclick,score_IDtemp_min=0,score_IDtemp=0] add per /scoreboard players tag @a[tag=noper] remove per /scoreboard players tag @a[tag=whoclick] add clicker /scoreboard players reset @a[tag=clicker] IDtemp /scoreboard players reset @a[tag=whoclick] ctemp /scoreboard players tag @a[tag=whoclick] remove whoclick

推送商店信息:

/scoreboard players add @a[tag=clicker] ctemp 1 /scoreboard players add @e[name=cShop,score_shopSetting=-1] cash 0 /execute @a[tag=noper,score_ctemp_min=1,score_ctemp=1] ~ ~ ~ execute @e[name=cShop,score_shopSetting=-1,c=1] ~ ~ ~ tellraw @p[tag=noper,score_ctemp_min=1,score_ctemp=1,r=8] [{"text":"[甘小蔗] ","color":"dark_green","bold":"true"},{"text":" 当前商品存库为","color":"green","bold":true},{"score":{"name":"@e[name=cShop,r=0,c=1]","objective":"items"},"color":"gold","bold":"true"},{"text":"\n在15秒内输入\u00a7c\u00a7l /trigger ibuy set 数量 \u00a7a\u00a7l进行购买,请在购买时不要移动","color":"green","bold":true}] /execute @a[tag=per,score_ctemp_min=1,score_ctemp=1] ~ ~ ~ /execute @e[name=cShop,score_shopSetting=-1,c=1] ~ ~ ~ tellraw @p[tag=per,score_ctemp_min=1,score_ctemp=1,r=8] [{"text":"[甘小蔗] ","color":"dark_green","bold":"true"},{"text":" 当前商店存有现金","color":"green","bold":true},{"score":{"name":"@e[name=cShop,r=0,c=1]","objective":"cash"},"color":"gold","bold":"true"},{"text":" 如需提现请在15秒内输入\u00a7c\u00a7l /trigger iget set 1 \u00a7a\u00a7l进行撤销\n","color":"green","bold":true},{"text":" 如需撤销请在15秒内输入\u00a7c\u00a7l /trigger delshop set 1 \u00a7a\u00a7l进行撤销","color":"green","bold":true}] /scoreboard players set @a[tag=noper,score_ctemp_min=1,score_ctemp=1] ibuy -1 /scoreboard players set @a[tag=per,score_ctemp_min=1,score_ctemp=1] delshop -1 /scoreboard players enable @a[tag=noper,score_ctemp_min=1] ibuy /scoreboard players enable @a[tag=per,score_ctemp_min=1] delshop /scoreboard players enable @a[tag=per,score_ctemp_min=1] iget /scoreboard players tag @a[tag=noper,score_ctemp_min=1,score_ctemp=299,score_ibuy_min=1] add buyer /scoreboard players add @a[tag=noper,score_ctemp_min=1,score_ctemp=299,score_ibuy_min=1] btimer 0 /scoreboard players tag @a[tag=per,score_ctemp_min=1,score_delshop_min=1,score_delshop=1,score_ctemp=299] add delshoper /scoreboard players tag @a[tag=per,score_ctemp_min=1,score_iget_min=1,score_iget=1,score_ctemp=299] add geter /execute @a[score_ctemp_min=1,score_ctemp=300] ~ ~ ~ tp @p[r=0] @p[r=0] /scoreboard players tag @a[score_ctemp_min=300] remove clicker /scoreboard players tag @a[score_ctemp_min=300] remove noper /scoreboard players tag @a[score_ctemp_min=300] remove per /scoreboard players reset @a[score_ctemp_min=300] ctemp

撤销执行部分:

/scoreboard players tag @a[score_delshop_min=1] remove per /scoreboard players reset @a[tag=delshoper] delshop /execute @a[tag=delshoper] ~ ~ ~ execute @e[name=cShop,score_shopSetting=-1,c=1] ~ ~ ~ setblock ~ ~ ~ air 0 destory /execute @a[tag=delshoper] ~ ~ ~ execute @e[name=cShop,score_shopSetting=-1,c=1] ~ ~ ~ scoreboard players reset @e[type=Item,tag=ishow,r=2] createitem /execute @a[tag=delshoper] ~ ~ ~ execute @e[name=cShop,score_shopSetting=-1,c=1] ~ ~ ~ entitydata @e[type=Item,tag=ishow,r=2] {PickupDelay:0,NoGravity:0,Item:{tag:{}}} /execute @a[tag=delshoper] ~ ~ ~ kill @e[name=cShop,score_shopSetting=-1,c=1] /tellraw @a[tag=delshoper] [{"text":"[甘小蔗] ","color":"dark_green","bold":"true"},{"text":" 撤销成功!","color":"red","bold":true}] /scoreboard players reset @a[tag=delshoper] ctemp /scoreboard players tag @a[tag=delshoper] remove createdShop /scoreboard players tag @a[tag=delshoper] remove delshoper

商店提现部分:

/scoreboard players tag @a[score_iget_min=1] remove per /scoreboard players reset @a[tag=geter] iget /execute @a[tag=geter] ~ ~ ~ /tellraw @p ["\u00a72\u00a7l[甘小蔗] ",{"score":{"name":"@e[name=cShop,score_shopSetting=-1,c=1]","objective":"cash"},"color":"gold","bold":"true"},"\u00a7a现金已经到账"] /execute @a[tag=geter] ~ ~ ~ scoreboard players operation @p[r=0] cash += @e[name=cShop,score_shopSetting=-1,c=1] cash /execute @a[tag=geter] ~ ~ ~ scoreboard players set @e[name=cShop,score_shopSetting=-1,c=1] cash 0 /scoreboard players reset @a[tag=geter] ctemp /scoreboard players tag @a[tag=geter] remove geter

购买执行部分:

/scoreboard players tag @a[score_ibuy_min=1] remove noper /scoreboard players add @a[tag=buyer,score_btimer_min=0] btimer 1 /scoreboard players set @a[tag=buyer,score_btimer_min=1,score_btimer=1] bpd 0 /execute @a[tag=buyer,score_btimer_min=1,score_btimer=1] ~ ~ ~ scoreboard players operation @p btemp = @p ibuy /execute @a[tag=buyer,score_btimer_min=1,score_btimer=1] ~ ~ ~ scoreboard players operation @p btemp -= @e[name=cShop,score_shopSetting=-1,c=1] items /scoreboard players set @p[score_btemp=0,score_btimer_min=1,score_btimer=1] bpd 1 /tellraw @a[score_bpd_min=0,score_bpd=0,score_btimer_min=1,score_btimer=1] [{"text":"[甘小蔗] ","color":"dark_green","bold":"true"},{"text":" 当前商品存库不足,购买失败","color":"red","bold":true}] /scoreboard players tag @a[score_bpd_min=0,score_bpd=0,score_btimer_min=1,score_btimer=1] remove buyer /scoreboard players reset @a[score_bpd_min=0,score_bpd=0,score_btimer_min=1,score_btimer=1] btimer /scoreboard players set @a[tag=buyer,score_btimer_min=2,score_btimer=2] bpd 0 /execute @a[tag=buyer,score_btimer_min=2,score_btimer=2] ~ ~ ~ scoreboard players operation @p btemp = @p ibuy /execute @a[tag=buyer,score_btimer_min=2,score_btimer=2] ~ ~ ~ scoreboard players operation @p btemp *= @e[name=cShop,score_shopSetting=-1,c=1] isale /execute @a[tag=buyer,score_btimer_min=2,score_btimer=2] ~ ~ ~ scoreboard players operation @p btemp -= @p cash /scoreboard players set @p[score_btemp=0,score_btimer_min=2,score_btimer=2] bpd 1 /tellraw @a[score_bpd_min=0,score_bpd=0,score_btimer_min=2,score_btimer=2] [{"text":"[甘小蔗] ","color":"dark_green","bold":"true"},{"text":" 您的现金不足,购买失败","color":"red","bold":true}] /scoreboard players tag @a[score_bpd_min=0,score_bpd=0,score_btimer_min=2,score_btimer=2] remove buyer /scoreboard players reset @a[score_bpd_min=0,score_bpd=0,score_btimer_min=2,score_btimer=2] btimer scoreboard players set @e[tag=selling] selling 0 /execute @a[tag=buyer,score_btimer_min=3] ~ ~ ~ scoreboard players set @e[name=cShop,score_shopSetting=-1,c=1] selling 1 tellraw @a[tag=buyer,score_btimer_min=3,score_btimer=3] [{"text":"[甘小蔗] ","color":"dark_green","bold":"true"},{"text":" 购买成功!请稍等片刻。","color":"green","bold":true}] /execute @a[tag=buyer,score_btimer_min=3] ~ ~ ~ scoreboard players remove @p ibuy 1 /execute @a[tag=buyer,score_btimer_min=3] ~ ~ ~ scoreboard players remove @e[name=cShop,score_shopSetting=-1,c=1] items 1 /execute @a[tag=buyer,score_btimer_min=3] ~ ~ ~ scoreboard players operation @p cash -= @e[name=cShop,score_shopSetting=-1,c=1] isale /execute @a[tag=buyer,score_btimer_min=3] ~ ~ ~ scoreboard players operation @e[name=cShop,score_shopSetting=-1,c=1] cash += @e[name=cShop,score_shopSetting=-1,c=1] isale /execute @a[tag=buyer,score_btimer_min=3] ~ ~ ~ scoreboard players operation @e[name=cShop,score_shopSetting=-1,c=1] savecash += @e[name=cShop,score_shopSetting=-1,c=1] isale /execute @e[name=cShop,score_shopSetting=-1,score_selling_min=1,tag=s_iron_ingot] ~ ~ ~ give @p[tag=buyer,score_btimer_min=3] iron_ingot 1 0 /execute @e[name=cShop,score_shopSetting=-1,score_selling_min=1,tag=s_reeds] ~ ~ ~ give @p[tag=buyer,score_btimer_min=3] reeds 1 0 /scoreboard players set @a[tag=buyer,score_btimer_min=3,score_ibuy=0] ibuy -1 /scoreboard players tag @a[tag=buyer,score_btimer_min=3,score_ibuy=0] remove buyer /scoreboard players reset @a[score_btimer_min=3,score_ibuy=0] ctemp /scoreboard players reset @a[score_btimer_min=3,score_ibuy=0] btimer


注意事项:

  • OOC以及地图中只支持铁锭和甘蔗的出售设置
  • 请右键箱子上方物品而不是告示牌
  • 不建议几个箱子紧密放在一起
  • 如果你发现右键出箱子菜单后无法移动,不要惊慌,隔几秒就好了



关于出售物品拓展:

本系统只能识别甘蔗(reeds)和铁锭(iron_ingot),不过你随意可以添加其他Item,只需要两部就能轻松完成。

首先,在商店设置部分中的/execute @e[name=cShop,score_shopSetting_min=2,score_shopSetting=2] ~ ~ ~ scoreboard players set @e[type=Item,r=1] createitem -2 {Item:{id:"minecraft:reeds",Count:1b,Damage:0s}}后添加/execute @e[name=cShop,score_shopSetting_min=2,score_shopSetting=2] ~ ~ ~ scoreboard players set @e[type=Item,r=1] createitem -3 {Item:{id:"minecraft:你要添加Item的英文ID",Count:1b,Damage:0s}},再在下方/execute @e[type=Item,score_createitem_min=-2,score_createitem=-2] ~ ~ ~ scoreboard players tag @e[name=cShop,c=1] add s_reeds添加/execute @e[type=Item,score_createitem_min=-3,score_createitem=-3] ~ ~ ~ scoreboard players tag @e[name=cShop,c=1] add s_你添加的Item的英文ID

最后,再在购买执行部分中/execute @e[name=cShop,score_shopSetting=-1,score_selling_min=1,tag=s_reeds] ~ ~ ~ give @p[tag=buyer,score_btimer_min=3] reeds 1 0后添加/execute @e[name=cShop,score_shopSetting=-1,score_selling_min=1,tag=s_你添加的Item的英文ID] ~ ~ ~ give @p[tag=buyer,score_btimer_min=3] 你添加的Item的英文ID 1 0就可以啦。



OOC:

创建与设置ooc:

展开

存货与购买与撤销ooc:

展开

OOC由PCB一键生成



更新/修复:

  1. 2017年12月1日:
    • 修复了补充货物时物品重叠的问题,指令部分,OOC部分均同步。存档内未同步。
  2. 2018年1月31日:
    • 修复了多人中的ShopID分配Bug
    • 修复了多人中的右键者身份识别
    • 优化OOC体验
  3. 2018年1月31日:
    • 修复大量Bug
    • 新增了提现功能
    • 版本更新为2.0


欢迎加群交流划水:481528679