• 1

    posted a message on [HELP] Detecting a player within a radius and applying an effect if they stay within that radius

    With your current setup, any players that are exactly 5 blocks away will gain blindness. To make it so that any players within 5 blocks get the effect, make it distance=..5. The .. makes it any players in the radius of up to 5, instead of exactly 5 blocks away. Similarly, if you want to make it so that any players 5 blocks or farther get an effect, all you would have to do is make it distance=5..


    Hope this helps! :)

    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on How do i detect a player leaving from my server with Command Blocks

    You can easily store when a player leaves the game with

    /scoreboard objectives add LeaveGame minecraft.custom:minecraft.leave_game

    then it will automatically store the data that a player left the game and how many times they leave, but in this scenario, I don't believe that you actually want to track when a player leaves the game, rather than just if all players on a specific team aren't there. Is that right? If so, what you should do instead is

    /execute if entity @a[team=Guards] unless entity @a[team=Prisoners]

    and

    /execute if entity @a[team=Prisoners] unless entity @a[team=Guards]

    You can either add a comparator coming from each command block, or add "run <command>" with chain command blocks coming from the first one that each execute their own command. With this setup, it runs 2 tests at once, one for if there are no prisoners online, and one for if there are no guards online. I will mention that with this setup, if the players aren't put on separate teams at the exact same time, then it will execute the command to end the game. To prevent this, add an x=insert x coordinate of the center of the prison,y=insert y coordinate of the center of the prison,z=insert z coordinate of the center of the prison,distance=..100 or however big the prison is in each direction from the center of the prison.


    Then all you have to do to make it work is teleport all the players in at the same time, or at least one prisoner and one guard at the same time before anyone else, and also make sure the waiting lobby, if there is one, isn't within a 100 block radius of the center of the prison. You could also do dx=,dy=,dz= for a more specific rectangular area, and therefore wouldn't have to worry about the waiting lobby being to close to the prison. Either way works.


    Sorry if that sounded a little too complex, but I hope you figure it out eventually! Hope this helps! :)

    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on How to give effects to a player if they are not near other players?

    Figured out a solution. If you make the @a[distance=..5] to be @a[distance=0.01..5] then it will only test for players outside of your exact location. I also added an "at @s" so that it would test for players within a 5-block radius of the player, rather than where the command block was situated. I totally forgot about that. Never thought it would be that simple ;P

    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on Help with last man standing with limited "lifes" commands

    What is the tag=ingameisla for? You shouldn't need a tag parameter if you're just checking for deaths. Also I'm not sure if this is the issue, but you don't need to have the scoreboard objective be for minecraft.custom:minecraft.deaths, because there is already a deathCount objective in scoreboard. If you remove the current objective you have for DeathCount, then do /scoreboard objectives add DeathCount deathCount then it might work better. I'm not sure if it's any different, but just thought I'd at least let you know that it was an option.


    To fix the issue, have an always active, unconditional, repeating command block with the command:

    /execute as @a[scores={DeathCount=..4}] at @s if entity @a[distance=0.01..] unless entity @a[distance=0.01..,scores={DeathCount=..4}] run tellraw @a [{"text":"","extra":[{"selector":"@s"}]},{"text":" has won the game!","color":"green"}]


    Then have an always active, conditional, chain command block stemming from the previous command block with the command:

    /scoreboard players set @a DeathCount 0


    Then, to set players to spectator after they reach 5 deaths, have an always active, unconditional, repeating command block with the command:

    /gamemode spectator @a[scores={DeathCount=5..}]


    Likewise, if you want to set all players back to survival after the game is over, so they can get out of spectator, have an always active, unconditional, repeating command block with the command:

    /gamemode survival @a[scores={DeathCount=..4}]


    You may want to add a name=!yourusername to the last command so that it doesn't always set you to survival, and that way you can keep messing with the commands. Or you may just not want the last command at all, it just resets the game easier.


    Also, if the chat is being spammed by it constantly saying your gamemode has been updated, or anything like that, do:

    /gamerule commandBlockOutput false

    /gamerule sendCommandFeedback false


    Hope this helps! :)

    Posted in: Commands, Command Blocks and Functions
  • To post a comment, please or register a new account.