1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT??:

    You can always check our our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Variable inside a variable?

Discussion in 'Skript' started by TheChromiumHorse, Dec 6, 2017.

Thread Status:
Not open for further replies.
  1. TheChromiumHorse

    Joined:
    Dec 6, 2017
    Messages:
    4
    Likes Received:
    0
    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 (Skript):
    1.  
    2. command /somecommand [<text>]:
    3.     trigger:
    4.         loop all players:
    5.             set {somevariable.player} to loop-player
    6.             make console execute command "/%arg 1%"
    7.  
    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!
     
  2. Laukage

    Laukage Active Member

    Joined:
    Jan 26, 2017
    Messages:
    33
    Likes Received:
    0
    You want to say hello to the players when they join or? please explain what u want it to do :emoji_slight_smile:
     
  3. TheChromiumHorse

    Joined:
    Dec 6, 2017
    Messages:
    4
    Likes Received:
    0
    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?
     
  4. ChisleLP

    ChisleLP Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    789
    Likes Received:
    59
    You need to evaluate for it.


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

    Code (Skript):
    1. broadcast "%arg-1%"
     
  5. TheChromiumHorse

    Joined:
    Dec 6, 2017
    Messages:
    4
    Likes Received:
    0
    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.
     
  6. FinalPlayer024

    FinalPlayer024 Well-Known Member

    Joined:
    Oct 19, 2017
    Messages:
    95
    Likes Received:
    3
    An example:

    Code (Skript):
    1. command /all [<text>]:
    2.   trigger:
    3.     loop all players:
    4.       make console execute command "/%arg 1% %loop-player%"
    5.       stop
    So, if the command after /all is "/kick", console will execute "/kick PlayerOnline1" "/kick PlayerOnline2" "/kick PlayerOnline3". did you mean that?
     
  7. TheChromiumHorse

    Joined:
    Dec 6, 2017
    Messages:
    4
    Likes Received:
    0
    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.
     
  8. SpectralMagic

    SpectralMagic New Member

    Joined:
    Oct 31, 2017
    Messages:
    4
    Likes Received:
    0
    this is why loop-player was invented I believe

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