• Hey! Register here to create your account, engage with the community, and talk about what is new!

get text in a @ command

Diceey

New member
Joined
Sep 20, 2021
Messages
15
Reaction score
0
How can i get the text a player sent from an @ command and make it as a broadcast for the players on the plot
 
Solution
You can check the command and then use trim and send the result to all players, to do it you place the Set Variable: TrimList block;
In the 1st slot of it's chest you put a variable of your choice (lets call it "bc"), in the 2nd slot you put the Event Command Arguments game value (to get it, get a name tag from the Values iron ingot, right click it, go to events and click on the bookshelf) and in the 3rd slot put a number 2 (i think, its maybe 1); now just place a Send Message, shift right click the sign and click on the beacon (All Players), open it's chest and put your variable (the one we called "bc") and it should send it to all players :D
1638683847572.png1638683861423.png

ARMcPro

Forum adept
Overlord
Joined
Oct 20, 2020
Messages
1,260
Reaction score
356
You can check the command and then use trim and send the result to all players, to do it you place the Set Variable: TrimList block;
In the 1st slot of it's chest you put a variable of your choice (lets call it "bc"), in the 2nd slot you put the Event Command Arguments game value (to get it, get a name tag from the Values iron ingot, right click it, go to events and click on the bookshelf) and in the 3rd slot put a number 2 (i think, its maybe 1); now just place a Send Message, shift right click the sign and click on the beacon (All Players), open it's chest and put your variable (the one we called "bc") and it should send it to all players :D
1638683847572.png1638683861423.png
 
Solution

Prox

Moderator
Moderator
Joined
Sep 9, 2020
Messages
384
Reaction score
31
a number 2 (I think, its maybe 1)
Lists begin indexing at 1 and the game event includes the text directly after the @. With that in mind, the final code should look something like this:

Code:
// The {} are the pistons from the If Game.
Player Event: Command
If Game: Command Equals (in the chest, a text: "bc", and set the tag to "check first word only") {
    // The If Game makes sure that we want to send this to every player. The command will now look like "@bc this is a message"
    Set Variable: Trim List (A variable: "message", Game Value: Event Command Arguments, A number: 2)
    // This takes a list of every word you sent and removes the first part. Now we have a list, ["this", "is", "a", "message"]
    Set Variable: Join Text (A variable: "message", A variable: "message", A text: " ")
    // This turns that list into what it originally was. To get the text " ", use /txt (space)
    // The variable "message" is now set to the text "this is a message"
    Player Action: Send Message [All Players] (A variable: "message")
    // This sends the variable to every player as a message, so it will send "this is a message" to every player.
    // To send it to every player, sneak and right click the sign, then click "all players."
    // If you want to send something else around the message, simply add that yourself as texts in other send messages.
} // This is the end of our code. Any other commands you want will go here.
 
Top Bottom