Solved Players in variables

  • 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!

utol

Member
Feb 10, 2017
17
1
0
25
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_language.skript:
on join:
    add player to {donators}

on disconnect:
    remove player to {donators}
    if {donators} is less than 0:
        set {donators} to 0

every 2 minutes:
    broadcast "Online Donators: %{Donators}%"
 
This would be for your first issue
code_language.skript:
on join:
    add "%player%" to {donators::*}
 
on disconnect:
    remove "%player%" to {donators::*}
    if {donators} is less than 0:
        set {donator.amount} to 0
 
every 2 minutes:
    broadcast "Online Donators: %{donator.amount}%"
 
This would be for your first issue
code_language.skript:
on join:
    add "%player%" to {donators::*}
 
on disconnect:
    remove "%player%" to {donators::*}
    if {donators} is less than 0:
        set {donator.amount} to 0
 
every 2 minutes:
    broadcast "Online Donators: %{donator.amount}%"
what do you mean first issue? :emoji_stuck_out_tongue:
[doublepost=1494761557,1494761483][/doublepost]
This would be for your first issue
code_language.skript:
on join:
    add "%player%" to {donators::*}
 
on disconnect:
    remove "%player%" to {donators::*}
    if {donators} is less than 0:
        set {donator.amount} to 0
 
every 2 minutes:
    broadcast "Online Donators: %{donator.amount}%"
also whats the purpose of {::*} ?
 
code_language.skript:
on join:
    add "%player%" to {donators::*}

on disconnect:
    remove "%player%" to {donators::*}

 
every 2 minutes:
    broadcast "Online Donators: %amount of {donators::*}%"
 
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::*}
 
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::*}

used your code but it only shows number of players, not the name it self. Help?