-2

I'm wondering about a potential command block program that will give a player a Unique id that I can use for multiple things. Just I need the command to pick up every single id that has joined that day (All ids reset at midnight) And know when they leave, so they can tag that id with leave when they join however it gives them the tag join. Once they join and lose the leave tag, they are given an actionbar message. If there is a simpler way please tell me!

Note: basically my goal here is to detect when someone leaves, and when they join gives them a message that is once per join. When they rejoin they get the message again, but never get it again per that session on the server.

Edit: So Its Kinda Of A Arena server so when you join I want to to say in the actiobar &7Welcome, You Are In Arena &C&l1. And Then Shut Off after about 2 seconds or so. The session is when someone joined until they leave. Not a first time join thing, it is sent every time the player joins.

7
  • Have you made any attempt to solve this yourself? Arqade works better when askers show effort to solve their own problems; we see that you have a problem you've worked on, and answerers respond to that. You also get a more specific answer that's tailored exactly to the part you're stuck, and Arqade gets a very specific question. Everybody wins!
    – Frank
    Commented Sep 9, 2017 at 23:16
  • Not your fault for being Mr. Bad Grammar, but I am struggling to understand, do you want to send an action bar message every time someone joins?
    – 54D
    Commented Sep 10, 2017 at 0:44
  • You mention tags being reset at midnight but then you also refer to a session as a length of time. Is a session one day? Is midnight real world time or minecraft time? Also, the section about join/leave tags and when you do/don't want messages sent is very difficult to understand. I would suggest editing the question.
    – IronAnvil
    Commented Sep 10, 2017 at 15:26
  • @Frank Yes I Have Tried, When the player leaves the get the tag join. If they have the join tag when they rejoin the server they get a message. Then the tag join is removed. Im stuck at the part where when they leave they are tagged with join in which restarts the cycle. @MBraedly I am glad you tryed to find a duplicate but my problem is I want the message to appear every time they join. @54D Thanks for not making fun of my grammar, and yes I do. @IronAnvil I kinda misused the word session in the question, and theres really no need for it to be there. Commented Sep 10, 2017 at 19:34
  • Great! So show us what you've tried. Effort helps us help you.
    – Frank
    Commented Sep 10, 2017 at 19:41

1 Answer 1

0

I have a solution that uses scoreboard with stat.leavegame

First, you have to create an objective. Type this into chat:

/scoreboard objectives add Leave stat.leaveGame

Then I used two chains of command blocks:

Blocks

Chain 1

The first command block sends the message to any player not tagged with Sent. I used tellraw in this example but this is where you would put your actionbar command. It is a repeating / unconditional / always active block with command:

tellraw @a[tag=!Sent] [{"text":"Welcome! You are in arena ","color":"gray"},{"text":"1","color":"red","bold":true}]

The second command block tags the untagged player with Sent. It is a chain / conditional / always active block with command:

scoreboard players tag @a[tag=!Sent] add Sent

Chain 2

The first command block removes the Sent tag from any player with a Leave score of 1 or higher. It is a repeating / unconditional / always active block with command:

scoreboard players tag @a[score_Leave_min=1] remove Sent

The second command block resets the Leave score of the player with a score of 1 or higher. It is a chain / conditional / always active block with command:

scoreboard players reset @a[score_Leave_min=1] Leave

On first join, player will be sent message and tagged. Once they leave, they will have a Leave score of one. When they rejoin, they will be untagged, and the score will reset. Then the first chain will send the message and tag them again.

In this example, every time I join, I see: Message

If you are wondering about the lever in my image, both of the repeating command blocks are set to Needs Redstone so I can turn it off.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.