我的世界多功能银行系统制作教程

2021-07-17 19:01:44

  整体思路:

  要实现存款和体现,需要两个计分板来储存这两个数据,在这里我用cash代表现金、deposit代表存款。首先,判定玩家是否在银行注册了用户,这里的银行用户都加入了YHuser队伍,所以直接用@a[team=!YHuser]就能选择到没有注册用户的玩家。

  存款和提现的处理:对于现金满足条件,就直接检测最近玩家的现金(cash)是否达到一定值(满足值),如果达到则减少最近玩家相应现金分值(cash),增加该玩家对应的相应存款(deposit)。因为本系统的现金额是大于等于0的,所以不满足只需要检测玩家现金(cash)分值是否为“0到满足值-1”即可。为什么要是“满足值-1”而不是“满足值”呢,因为MC中计分板是整数,所以如果包含了那个数,玩家现金分数刚好为满足值,那么玩家岂不是既满足了现金满足条件,又满足了现金不满足条件了。其次是这里的判定需要用到scoreboard players test @P cash 满足值 *,因为如果用testfor @p[score_cash_min=满足值]则在多人游戏中游戏会选择最近的符合条件的玩家,而不是最近玩家。

  玩家死亡掉落现金其实很简单,就在原有判定死亡的基础上,将死亡玩家的现金(cash)减去100或50。这里的普通用户会有一个ptuser的tag标签,付费用户为ffuser标签。所以分别@a[tag=ptuser&ffuser]就能选中所有的银行用户。

  对于现金超支的判定,即现金(cash)小于0(小于等于-1),若玩家cash小于0的时候,用玩家的deposit+=cash两次即可。因为此时玩家的现金(cash)为负数,所以这时的deposit+=cash就等于deopsit-=|cash|;若执行两次,就等于deopsit-=2|cash|。即减去存款值=超支现金x2。

  代码:

  创建变量:

  /scoreboard objectives add cash dummy 现金

  /scoreboard objectives add deposit dummy 存款

  /scoreboard teams add YHuser

  /scoreboard objectives add cashlose deathCount

  初始化:[高频循环]

  /scoreboard players add [url=home.php?mod=space&uid=311230]@A[/url] cash 0

  /scoreboard players add @a deposit 0

  新人福利:[高频循环]

  /scoreboard players add @a[team=!YHuser] deposit 100

  /execute @a[team=!YHuser] ~ ~ ~ tellraw @p[r=0] [{"text":"[甘小蔗银行] ","color":"gold","bold":"true"},{"selector":"@p","color":"gold","bold":"true"},{"text":" 检测到您还未注册账户,本银行已自动为您注册,并为您预存了100元整存款。","color":"green"}]

  /scoreboard players tag @a[team=!YHuser] add ptuser

  /scoreboard teams join YHuser @a[team=!YHuser]

  银行资质显示:[高频循环]

  /execute @a[team=YHuser,tag=ptuser] ~ ~ ~ title @p[r=0] actionbar [{"selector":"@p","color":"dark_green","bold":"true"},{"text":",您是银行","color":"green","bold":"true"},{"text":"普通用户","color":"gold"},{"text":" | ","color":"aqua","bold":"true"},{"text":"您的当前现金:","color":"green","bold":true},{"score":{"name":"@p","objective":"cash"},"color":"gold","bold":"true"},{"text":" | ","color":"aqua","bold":"true"},{"text":"您的当前存款:","color":"green","bold":true},{"score":{"name":"@p","objective":"deposit"},"color":"gold","bold":"true"}]

  /execute @a[team=YHuser,tag=ffuser] ~ ~ ~ title @p[r=0] actionbar [{"selector":"@p","color":"gold","bold":"true"},{"text":",您是银行","color":"green","bold":"true"},{"text":"付费用户","color":"gold"},{"text":",尊享消费特权","color":"green","bold":"true"},{"text":" | ","color":"aqua","bold":"true"},{"text":"您的当前现金:","color":"green","bold":true},{"score":{"name":"@p","objective":"cash"},"color":"gold","bold":"true"},{"text":" | ","color":"aqua","bold":"true"},{"text":"您的当前存款:","color":"green","bold":true},{"score":{"name":"@p","objective":"deposit"},"color":"gold","bold":"true"}]

  存款与提现:

  本部分中条件约制对版本有要求,如游戏版本不支持条件约制,则需要布线来判定,详情见演示地图。

  存款:

  scoreboard players test @p cash 100 *

  scoreboard players remove @p cash 100 (条件约制)

  scoreboard players add @p deposit 100 (条件约制)

  tellraw @p [{"text":"[甘小蔗银行] ","color":"gold","bold":"true"},{"selector":"@p","color":"dark_green","bold":"true"},{"text":" 您已成功存款100元","color":"green"}] (条件约制)

  scoreboard players test @p cash 0 99

  tellraw @p [{"text":"[甘小蔗银行] ","color":"gold","bold":"true"},{"selector":"@p","color":"dark_green","bold":"true"},{"text":" 您的现金不足","color":"red"}] (条件约制)

  提现:

  scoreboard players test @p deposit 100 *

  scoreboard players remove @p deposit 100 (条件约制)

  scoreboard players add @p cash 100 (条件约制)

  tellraw @p [{"text":"[甘小蔗银行] ","color":"gold","bold":"true"},{"selector":"@p","color":"dark_green","bold":"true"},{"text":" 您已成功提现100元","color":"green"}] (条件约制)

  scoreboard players test @p deposit 0 99

  tellraw @p [{"text":"[甘小蔗银行] ","color":"gold","bold":"true"},{"selector":"@p","color":"dark_green","bold":"true"},{"text":" 您的存款不足","color":"red"}] (条件约制)

  成为付费用户:(可以重复开通)

  scoreboard players test @p cash 10000 *

  scoreboard players remove @p cash 10000 (条件约制)

  scoreboard players tag @p[tag=ptuser] add ffuser (条件约制)

  scoreboard players tag @a[tag=ffuser] remove ptuser (条件约制)

  tellraw @p [{"text":"[甘小蔗银行] ","color":"gold","bold":"true"},{"selector":"@p","color":"gold","bold":"true"},{"text":" 您已成为银行付费用户!尊享消费特权!","color":"green"}] (条件约制)

  scoreboard players test @p cash 0 9999

  tellraw @p [{"text":"[甘小蔗银行] ","color":"gold","bold":"true"},{"selector":"@p","color":"dark_green","bold":"true"},{"text":" 您的现金不足","color":"red"}] (条件约制)

  死亡现金掉落:

  银行普通用户:

  /scoreboard players remove @a[score_cashlose_min=1,tag=ptuser] cash 100

  /execute @a[score_cashlose_min=1,tag=ptuser] ~ ~ ~ tellraw @a [{"text":"[甘小蔗银行] ","color":"gold","bold":"true"},{"selector":"@a[score_cashlose_min=1]","color":"dark_green","bold":"true"},{"text":" 死亡掉落了100现金","color":"dark_red"}]

  银行付费用户:

  /scoreboard players remove @a[score_cashlose_min=1,tag=ffuser] cash 50

  /execute @a[score_cashlose_min=1,tag=ffuser] ~ ~ ~ tellraw @a [{"text":"[甘小蔗银行] ","color":"gold","bold":"true"},{"selector":"@a[score_cashlose_min=1]","color":"gold","bold":"true"},{"text":" 死亡掉落了50现金","color":"dark_red"}]

  /scoreboard players reset @a[score_cashlose_min=1] cashlose

  现金超支惩罚:

  /scoreboard players tag @a[score_cash=-1] add nocash

  /execute @a[tag=nocash] ~ ~ ~ scoreboard players operation @p[r=0] deposit += @p[r=0] cash

  /execute @a[tag=nocash] ~ ~ ~ scoreboard players operation @p[r=0] deposit += @p[r=0] cash

  /execute @a[tag=nocash] ~ ~ ~ tellraw @p [{"text":"[甘小蔗银行] ","color":"gold","bold":"true"},{"selector":"@p[r=0]","color":"gold","bold":"true"},{"text":" 由于你的现金不足超支,已在存款中按超支的双倍扣除!","color":"dark_red"}]

  /scoreboard players set @a[tag=nocash] cash 0

  /scoreboard players tag @a[tag=nocash] remove nocash

特色标签

精彩合集,奇葩无下限 更多

最新游戏

更多

最新专题

更多

相关文章