Solved Variable inside a variable?

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.
Dec 6, 2017
4
0
0
27
Skript Version: latest stable version
Skript Author: Bensku
Minecraft Version: 1.8.8

Hello there,
As I described in the title, I am attempting to use a variable inside another variable.
I know about {variable.%player%}, but here I think I need something more specific.
Anyway, here's my code:
code_language.skript:
command /somecommand [<text>]:
    trigger:
        loop all players:
            set {somevariable.player} to loop-player
            make console execute command "/%arg 1%"
What did I expect?
Let's say I have Notch and Dinnerbone on my server.
> somecommand say Hello, %{somevariable.player}%
< [Server] Hello, Notch
< [Server] Hello, Dinnerbone

What actually happened?
The replication of the command was
< [Server] Hello, %{somevariable.player}%
< [Server] Hello, %{somevariable.player}%

Any tip/suggestion/advice is going to be highly welcomed!
Appreciations in advance!
 
You want to say hello to the players when they join or? please explain what u want it to do :emoji_slight_smile:
 
You want to say hello to the players when they join or? please explain what u want it to do :emoji_slight_smile:
I am trying to execute a command, including each player's name it.
Having the players "Player1", "Player2", "Player3", etc. and executing the command "/somecommand givecrate %{somevariable.player}%" should give a crate to all players.
So what's the sense?
There is no /giveallcrate command, so the only possible way to give a player a crate is by typing each player's name. And that's what I am trying to achieve. Do not suggest me any crate plugins! The crate is just an example. I may need to ban all online players ;P (/somecommand ban %{somevariable.player}%)
So in the case `/somecommand ban %{somevariable.player}% Bye!`, or `/somecommand givecrate %{somevariable.player}%` the script should make the Console execute:
/ban Player1 Bye!
/ban Player2 Bye!
/ban Player3 Bye!
....
or in the case with the crate:
/givecrate Player1
/givecrate Player2
/givecrate Player3
/givecrate Player4
....

Got it?
 
You need to evaluate for it.


But if you use broadcast. you don't need it I believe (My brain is confused now)

code_language.skript:
broadcast "%arg-1%"
 
You need to evaluate for it.


But if you use broadcast. you don't need it I believe (My brain is confused now)

code_language.skript:
broadcast "%arg-1%"
I do not fully understand, but I got an idea. Maybe split %arg 1% by {player}?
I am going to try this right now, and I post my code if someone else is also interested.
 
An example:

code_language.skript:
command /all [<text>]:
  trigger:
    loop all players:
      make console execute command "/%arg 1% %loop-player%"
      stop
So, if the command after /all is "/kick", console will execute "/kick PlayerOnline1" "/kick PlayerOnline2" "/kick PlayerOnline3". did you mean that?
 
An example:

code_language.skript:
command /all [<text>]:
  trigger:
    loop all players:
      make console execute command "/%arg 1% %loop-player%"
      stop
So, if the command after /all is "/kick", console will execute "/kick PlayerOnline1" "/kick PlayerOnline2" "/kick PlayerOnline3". did you mean that?
This will only work if you place the player's name at the end of the command - having arguments after it won't be possible.
 
this is why loop-player was invented I believe

use loop-player where ever you want to test all players
 
Status
Not open for further replies.