Solved Add a string to a list

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

    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.

LoneElf

Active Member
Apr 30, 2017
165
2
18
Hi! So, I am making a teams skript like I said in another skript, but it is like factions, but just for pvp, so you can't hit players in your team. So, this is my code I have for creating your team:
code_language.skript:
variables:
    team = " " parsed as a string

command /team [<text>] [<text>]:
    trigger:
        if arg 1 is not set:
            if arg 2 is not set:
                message ""
                message "&f&l&m-------------------"
                message "        &8»  &7Teams  &8«"
                message ""
                message "  &b/team create <name>"
                message "  &b/team invite <player>"
                message "  &b/team join <team>"
                message "  &b/team mod <player>"
                message "  &b/team admin <player>"
                message "  &b/team owner <player>"
                message "  &b/team demote <player>"
                message "  &b/team kick <player>"
                message "  &b/team disband"
                message "&f&l&m-------------------"
                message ""
        if arg 1 is "create":
            if arg 2 is set:
                if {team.in.%uuid of player%} is true:
                    message "&c&l!!  &7You are already in a team! Type /team leave!"
                else:
                    message "&8[&9Teams&8] &bYou have created a team named %arg-2%!"
                    set {team.in.%uuid of player%} to true
                    add arg 2 to {teams}
                    set {team.leader.%uuid of player%} to true

Ok, so I need argument 2 (the name of the created team) to be added to a list. Now, I don't know how to make a list of strings. Also, if I had that, how would I order them so it would be like this:

Teams:
1. A team name that has been added to {teams}
2. So forth and so forth

Thanks guys! :emoji_slight_smile:
[doublepost=1493599980,1493589518][/doublepost]Anybody? Please! I really need this!
[doublepost=1493607516][/doublepost]Please help me! :emoji_stuck_out_tongue: I really need this done! Thanks :emoji_slight_smile:
 
Code:
#add the name
add arg 2 to {teams::*}

#send the list
loop {teams::*}:
    message "%loop-index% %loop-value%"
 
Thanks! Can you explain it for me? xD Im sorry! I just like to know what it does so I can improve on it and make it my own! :emoji_slight_smile: Thanks
 
It's all in the docs but here's the rundown:

A list looks like this: {list name::*}

Then you add values to the list variable with this:
add whatever (in your case, arg 2) to {list name::*}

Then you can loop through the values inside the list with:
loop {list name::*}

loop-index gives you the the current number of the value being looped if that makes sense.

loop-value gives you the value being currently looped (the stuff you add to the list).
 
Status
Not open for further replies.