TransWikia.com

is there a way to calculate the greater and smaller of player scoreboard values in minecraft?

Arqade Asked by willywillycow on March 16, 2021

So I am trying to make a map, there is a scoreboard objective called anger that when a player’s anger is greater than 300, player will sometime floats. when the player’s anger is greater than 1000, he randomly explodes, but I do not know how to use command blocks to calculate if the player’s anger is greater or smaller, anyone can help?

One Answer

The way to test for scores you can do with this command:

execute as @a[scores={Anger=300..1000}] if entity @s run effect give @s levitation 1 0

This will give all players with the Anger score a levitation effect for 1 second with the amplifier of 1, the 0 at the end is the amplifier, i.e. 0 will give you an amplifier of 1, 1 will give you an amplifier of 2, etc.

You can also add true at the end to hide the effect particles:

effect give @s levitation 1 0 true

The first command will test for when a player has an Anger score from 300 to 1000. I don't really know how to make a randomizer but if you use another scoreboard you can add the levitation effect every 20 seconds or whatever delay you'd like.

/scoreboard objectives add Random dummy

Then you can put this in a repeating command block:

scoreboard players add @a Random 1

This will add 1 point every 20:th of a second to the score, so 20 points a second. Using this you can test for how many seconds you'd like the delay to be by just testing for a score 20 times bigger, lets say we want a 20-second delay:

execute as @a[scores={Random=400..400,Anger=300..1000}] if entity @s run 
effect give @s levitation 1 0

After this you put a chain command block with a command that resets the Random score:

execute as @a[scores={Random=400..400,Anger=300..1000}] if entity @s run 
scoreboard players set @s Random 0

You can do the same with the above 1000 scenario, and you can add another dummy score if you'd like the delay to be different from your first.

About the score testing:

When you test for a score you do that within the target selector, @a[scores={"here"}]. You specify the score's name first, @a[scores={Anger=}, then you add the score you'd like to test for using 2 dots ... In front of the dots is the minimum score, and after is the maximum score, If I'd like to test for a score from 0 to 347 I'd write:

execute as @a[scores={Anger=..347}] if entity @s run *command*

And if I'd like to test for a score of 1000 or more I'd write:

execute as @a[scores={Anger=1000..}] if entity @s run *command*

Make sure to add the if entity @s after the selector @a[]. This makes sure the command only runs when the players' scores actually are correct, so the player doesn't get stuck in a loop.

Correct answer by Semlan Bakelsen on March 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP