如题,因为死亡重生后原本attribute给的属性会重置为默认值,就想写一个函数恢复。有计分板death记录死亡次数,tick函数:execute if entity @a[scores={death=1..}] run function cs:intensify/playerattribute 函数cs:intensify/playerattribute里写的是attribute指令,瞬间治疗(因为要改max_health,让复活后满血)以及使计分板重置为0。
但是问题是在我死的瞬间,death计分板=1,tick函数激活,运行playerattribute,此时我处于死亡状态,导致attribute无效但重置了计分板,复活后death计分板为0,而我却没吃到attribute以及瞬间治疗...
如何解决?
但是问题是在我死的瞬间,death计分板=1,tick函数激活,运行playerattribute,此时我处于死亡状态,导致attribute无效但重置了计分板,复活后death计分板为0,而我却没吃到attribute以及瞬间治疗...
如何解决?
 本帖最后由 会点指令 于 2020-8-16 02:31 编辑 
弄个延时?
延时弄个0.1秒就没问题的
弄个延时?
延时弄个0.1秒就没问题的
 本帖最后由 Peanutz_OwO 于 2020-8-16 17:34 编辑 
刚刚试了试发现好像这样也可以,什么原理?
复制代码
刚刚试了试发现好像这样也可以,什么原理?
- execute as @e[type=player,scores={death=1..}] run function cs:intensify/playerattribute
 
 
- # 记得把 cs:intensify/playerattribute 中 /attribute 和 /effect 的目标改为 @s
简单
execute if entity @e[type=player,scores={death=1..}] run function
execute if entity @e[type=player,scores={death=1..}] run function
死亡时能被@a选择器选择到,不能被@p选择器选择到,也不能被@e[type=player]选择到...真是神奇,确实是只要改成@e[type=player]就可以了