The Meaning of Life, the Universe, and Everything.
Join Date:
2/24/2015
Posts:
226
Minecraft:
Lightwavers
Member Details
What I want to do is record how long a player has been sneaking, but reset it to 0 and keep it there until they sneak again, at which point it will start to increase. This will be used for things such as
1. a shock-wave type effect that will do damage to other entities in a radius, doing more damage as the time increases.
2. increasing damage dealt while sneaking and hitting an entity facing away from the player.
3. making the player invisible when having been sneaking for a sufficiently long amount of time, until stopped sneaking or hitting/being hit by something.
You should not be mixing a nested @p with an executor of @a. While @a can target dead players, @p cannot. A dead player will run the /scoreboard command, but instead of targeting themselves, they'll target the nearest-living player. This can cause serious conflicts depending on the mechanism.
You should only use similar selectors, such as @a with @a[c=1] or @e[type=Player] with @p:
What I want to do is record how long a player has been sneaking, but reset it to 0 and keep it there until they sneak again, at which point it will start to increase. This will be used for things such as
1. a shock-wave type effect that will do damage to other entities in a radius, doing more damage as the time increases.
2. increasing damage dealt while sneaking and hitting an entity facing away from the player.
3. making the player invisible when having been sneaking for a sufficiently long amount of time, until stopped sneaking or hitting/being hit by something.
⠀
s̮̹̃rͭ͆̄͊̓̍ͪ͝e̮̹̜͈ͫ̓̀̋̂v̥̭̻̖̗͕̓ͫ̎ͦa̵͇ͥ͆ͣ͐w̞͎̩̻̮̏̆̈́̅͂t͕̝̼͒̂͗͂h̋̿
You will need 2 scoreboard objectives:
scoreboard objectives add sneak1 stat.sneakTime
scoreboard objectives add sneak2 dummy
Have a repeating command block with the command:
/scoreboard players set @a[score_sneak1=0] sneak2 0
Then, have a chain command block connected to the repeating command bloc with the command:
/execute @a ~ ~ ~ /scoreboard players operation @p sneak2 += @p sneak1
Add another chain command block with the command:
/scoreboard players set @a sneak1 0
Ta Da!
YouTube: https://www.youtube.com/channel/UCzGDRYWcrGreMmQFo_d5N5Q
Facebook:https://goo.gl/s0r12d
Website:https://theusaf.weebly.com
JavaScript Projects: https://theusaf.github.io
Link Shortener: https://shortr.github.io
Twitter:https://www.twitter.com/theusafyt
Thanks so much!
⠀
s̮̹̃rͭ͆̄͊̓̍ͪ͝e̮̹̜͈ͫ̓̀̋̂v̥̭̻̖̗͕̓ͫ̎ͦa̵͇ͥ͆ͣ͐w̞͎̩̻̮̏̆̈́̅͂t͕̝̼͒̂͗͂h̋̿
You should not be mixing a nested @p with an executor of @a. While @a can target dead players, @p cannot. A dead player will run the /scoreboard command, but instead of targeting themselves, they'll target the nearest-living player. This can cause serious conflicts depending on the mechanism.
You should only use similar selectors, such as @a with @a[c=1] or @e[type=Player] with @p:
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/