下面小编为大家带来我的世界禁止玩家修改计分板教程,想学的玩家别错过这个不错的教程!
首先我们需要浪费一点时间来创建这四个变量,噢等等,我们还没有构思这个功能并让他可以在多人中工作,就像焚烧厂一样,即使垃圾再多也可以处理掉,当然我并不是把多人跟垃圾作比较...接下来让我们开始吧! [阅读下方内容你至少应该接触计分板,如果没有也不要紧,你只需要关掉此页面即可]
在构思的过程中,先不要管你用了多少指令,先实现后优化也是可行的,这里的优化不单单指复杂度的优化,还有功能的优化。就像某橡胶厂家生产神奇的物品一样,先生产,再测试舒适度,润滑度,然后根据需求再返工一样。Ouch,我也许不该说这些...
言归正传,你首先需要一个计分板来让玩家修改,例如score(以下变量准则都为dummy),然后如何检测到玩家修改这个指令,这里我们就需要用到operation里的-=运算符,如果你还没接触也没关系,我在后面强行塞给你就好了。这里有个检测两个变量值不一样的小技巧,就是让两个变量值相减,如果至=0则相同,很简单的道理吧,接下来还有更简单的。再创建一个noScoreGet0变量,并且使他与变量score的值相同,然后用noScoreGet0的值减去score,如果值不等于0则玩家就修改了计分板。[OS: 我看你他妈就在废话]
!QAQ,第一次写教程不知道怎么入手,本来想让教程变得有趣一些,但在我手中就像干货中掺水了一样...所以我还是甩代码...
/scoreboard objectives add score dummy 分数
/scoreboard objectives add noScoreGet0 dummy 防修改参数0
/scoreboard objectives add noScoreGet1 dummy 防修改参数1
/scoreboard objectives add getCheckVer dummy 获取修改值
part1
scoreboard players set @a[score_score=-1] score 0
execute @a ~ ~ ~ scoreboard players operation @p[r=0] noScoreGet0 -= @p[r=0] score
scoreboard players tag @a[score_noScoreGet0=-1] add checkScore
scoreboard players tag @a[score_noScoreGet0_min=1] add checkScore
part2
execute @a[tag=!checkScore] ~ ~ ~ scoreboard players operation @p[r=0] noScoreGet0 = @p[r=0] score
execute @a[tag=checkScore] ~ ~ ~ scoreboard players operation @p[r=0] getCheckVer = @p[r=0] score
execute @a[tag=!checkScore] ~ ~ ~ scoreboard players operation @p[r=0] noScoreGet1 = @p[r=0] score
execute @a[tag=checkScore] ~ ~ ~ scoreboard players operation @p[r=0] noScoreGet0 = @p[r=0] noScoreGet1
execute @a[tag=checkScore] ~ ~ ~ scoreboard players operation @p[r=0] score = @p[r=0] noScoreGet0
part3
execute @a[tag=checkScore] ~ ~ ~ tellraw @a [{"text":"玩家 ","color":"red"},{"selector":"@a[tag=checkScore]","color":"dark_red","bold":true},{"text":" 试图将自身分数修改为","color":"red","bold":true},{"score":{"name":"@p[tag=checkScore]","objective":"getCheckVer"},"color":"gold","bold":"true"},{"text":",已被机智的甘蔗阻拦!","color":"red","bold":true}]
scoreboard players tag @a[tag=checkScore] remove checkScore
最后!修改方法就是同时执行以下指令:
/scoreboard players set MCSugar_cane noScoreGet0 100
/scoreboard players set MCSugar_cane score 100
19游戏网整理报道