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!

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

Solved Players in variables

Discussion in 'Requests' started by utol, May 14, 2017.

  1. utol

    utol Member

    Joined:
    Feb 10, 2017
    Messages:
    17
    Likes Received:
    1
    Hey i'm currently figuring out on how to list the players are in the variable?

    And very detailed.

    Example:
    Online Donators: Player, Player < players that are in the variable.
    If the variable has no players or its null, set the variable to " "

    Test Skript that i made:


    Code (Skript):
    1. on join:
    2.     add player to {donators}
    3.  
    4. on disconnect:
    5.     remove player to {donators}
    6.     if {donators} is less than 0:
    7.         set {donators} to 0
    8.  
    9. every 2 minutes:
    10.     broadcast "Online Donators: %{Donators}%"


     
  2. Best Answer:
    Post #10 by ShaneBee, May 19, 2017
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    This would be for your first issue
    Code (Skript):
    1. on join:
    2.     add "%player%" to {donators::*}
    3.  
    4. on disconnect:
    5.     remove "%player%" to {donators::*}
    6.     if {donators} is less than 0:
    7.         set {donator.amount} to 0
    8.  
    9. every 2 minutes:
    10.     broadcast "Online Donators: %{donator.amount}%"
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    what do you mean first issue? :emoji_stuck_out_tongue:
    --- Double Post Merged, May 14, 2017, Original Post Date: May 14, 2017 ---
    also whats the purpose of {::*} ?
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    Code (Skript):
    1. on join:
    2.     add "%player%" to {donators::*}
    3.  
    4. on disconnect:
    5.     remove "%player%" to {donators::*}
    6.  
    7.  
    8. every 2 minutes:
    9.     broadcast "Online Donators: %amount of {donators::*}%"
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    thanks but what is the purpose of {::*} ??
     
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    It's a loop-variable: SkUnity
     
  8. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    basically it shortens the code without you writing loop all players: ?
     
  9. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    List variables are variables which can hold multiple values. They look like {variable name::*} and can have elements added and removed from them using the default add and remove effects, can be deleted which will clear all values of the list, and overwritten with new values with the set effect. You can access a specific value of a list variable with {variable name::index} where ‘index’ is the index of the value you want. The index can be anything, e.g. a player name or a number, but when adding values to the list with the add effect the index of the new value will be a number.

    List variables can be looped with loop {list variable::*}. Within the loop the currently looped value can be accessed with loop-value and its index with loop-index.

    List variables are also useful to show a list in a message, e.g. a list of all admins online, by first adding them to the same list variable and then using that variable in the message (see the last example below). Using a local list variable for this purpose is recommended: {_local list variable::*}
     
  10. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    used your code but it only shows number of players, not the name it self. Help?
     
  11. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    just "%{Donators::*}%"
     

Share This Page

Loading...