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!


    You can always check out 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.

Single variables to List variables

Discussion in 'Skript' started by SoMuchWessel, May 24, 2017.

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

    SoMuchWessel Active Member

    Apr 3, 2017
    Likes Received:
    Hey guys,

    I use a lot of single variables in my code, which is a bit unefficient. So I want to learn more about list variables and how they work.
    But what i want more is how to convert some of my single variables into list variables, doing the same thing.

    Like here i have some examples of single variables that i use a lot in my codes:

    Code (Skript):
    1. set {%player%.secondary} to true
    2. set {%player%.count} to 1
    3. if {%player%.team} = true:
    4. add 1 to {%player%.team}
    5. subtract 1 from {arena1.redteam}
    Can you guys help me with list variables, and converting those single variable examples into list variables?
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Sep 7, 2017
    Likes Received:
    Maybe this will work:

    Code (Skript):
    1. command /variabletransform
    2.   permission: skript.admin
    3.   trigger:
    4.     if {arena1.redteam} is set:
    5.       set {arena::redteam} to {arena1.redteam}
    6.     loop all offline players:
    7.       if {%loop-player%.secondary} is set:
    8.         set {secondary::%loop-player%::*} to {%loop-player%.secondary}
    9.       if {%loop-player%.count} is set:
    10.         set {count::%loop-player%::*} to {%loop-player%.count}
    11.       if {%loop-player%.team} is set:
    12.         set {team::%loop-player%::*} to {%loop-player%.team}
    14. command /oldvariabledelete
    15.   description: This will delete the old variables that you'll not need anymore. JUST USE THIS WHEN SURE EVERYTHING IS CORRECT WITH THE NEW VARIABLES!
    16.   permission: skript.admin
    17.   trigger:
    18.     loop all offline players:
    19.       clear {%loop-player%.secondary}
    20.       clear {%loop-player%.count}
    21.       clear {%loop-player%.team}
    22.       clear {%loop-player%.team}
    23.       clear {arena1.redteam}
    Just use the second command after you test the values of the first one.
    I don't know what this variables do, so you gotta see if this fits you, but I think the variables I set will work.

    Now, for example, if you want to delete all players count, you just do:

    Code (Skript):
    1. clear {count::*}
    And it will delete all count from all players at once, in one line of code.
Thread Status:
Not open for further replies.

Share This Page