List Variable Problems

  • Thread starter Deleted member 6377
  • Start date
  • 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.
D

Deleted member 6377

Using newest version of skript for 1.8.9.

No add-ons. I’d like to keep it this way.


Problems:

1. How do I check the amount of players in a list variable? (if the sumo event has only 1 player in it, it will stop the event from starting)

2. When 2 random players get selected from a list variable, how do I make it so it’s never the same person? I ran into this problem when creating a different skript.

3. In a sumo event, how do I make it so it will keep picking random people and making them duel until 1 player is left?

A simple version of my code for #2 and #3
code_language.skript:
set {_match1-1} to random element out of {sumoplayers::*}
set {_match1-2} to random element out of {sumoplayers::*}
# other stuff happens
teleport {_match1-1} to {espawn1}
teleport {_match1-2} to {espawn2}
# other stuff happens
^ In my code, the event will only execute 1 match. How do I make it so it keeps repeating it (however many player joins the event) until only 1 player is left? The player that is left would be the winner.
 
Using newest version of skript for 1.8.9.

No add-ons. I’d like to keep it this way.


Problems:

1. How do I check the amount of players in a list variable? (if the sumo event has only 1 player in it, it will stop the event from starting)

2. When 2 random players get selected from a list variable, how do I make it so it’s never the same person? I ran into this problem when creating a different skript.

3. In a sumo event, how do I make it so it will keep picking random people and making them duel until 1 player is left?

A simple version of my code for #2 and #3
code_language.skript:
set {_match1-1} to random element out of {sumoplayers::*}
set {_match1-2} to random element out of {sumoplayers::*}
# other stuff happens
teleport {_match1-1} to {espawn1}
teleport {_match1-2} to {espawn2}
# other stuff happens
^ In my code, the event will only execute 1 match. How do I make it so it keeps repeating it (however many player joins the event) until only 1 player is left? The player that is left would be the winner.
1. You can use size of <list> to get the size of the list
2.
code_language.skript:
set {_l::*} to {sumoplayers::*}
set {_match1-1} to random element out of {_l::*}
remove {_match1-1} from {_l::*}
set {_match1-2} to random element out of {_l::*}
3. Can you send your full code for this one?
 
Also, do you mind explaining to me how your code would work? Trying to learn about list variables a bit more. Thanks!
Okay sure, I'll try to explain it with comments:
code_language.skript:
set {_l::*} to {sumoplayers::*} # Here I basically set a list variable to the original list, because I don't want modify the original list
set {_match1-1} to random element out of {_l::*} # This part is actually just the same as your code, it sets a variable for later usage to a random element from the list which we just set
remove {_match1-1} from {_l::*} # Here I remove the last chosen random element from the list, so that it can't be randomly picked out of the list on the following line
set {_match1-2} to random element out of {_l::*} # Again, the same as your code, but now the list {_l::*} does not include your first randomly picked object, so that it can't be randomly picked again
 
  • Like
Reactions: Deleted member 6377
Nothing as of now. I literally just started making it and voila these problems popped into my mind.
Then I think it's the best if you start on making it able to do 1 round, and when it's finished, remove the players who lost that round from the variable and run the whole code again, until there is one player left.
 
Then I think it's the best if you start on making it able to do 1 round, and when it's finished, remove the players who lost that round from the variable and run the whole code again, until there is one player left.
Umm, how would I do that? That’s exactly what I wanted to know lol

Also running the whole code again won’t be good, how do I make it so it only runs some lines of code again?
 
Last edited by a moderator:
Umm, how would I do that? That’s exactly what I wanted to know lol

Also running the whole code again won’t be good, how do I make it so it only runs some lines of code again?
Do you also need help with the game ending part or just the restarting? Because if it's just the restarting, I would make the ending first and worry about the restarting later.
 
Do you also need help with the game ending part or just the restarting? Because if it's just the restarting, I would make the ending first and worry about the restarting later.
code_language.skript:
                    wait 3 seconds
                                                set {_ml::*} to {sumoplayers::*}
                                                set {_match1-1} to random element out of {_ml::*}
                                                remove {_match1-1} from {_ml::*}
                                                set {_match1-2} to random element out of {_ml::*}
                                                remove {_match1-2} from {_ml::*}
                                                loop {sumoplayers::*}:
                                                    send "{@prefix} &6%{_match1-1}% &dvs &6%{_match1-2}%" to loop-value
                                                teleport {_match1-1} to {espawn1}
                                                teleport {_match1-2} to {espawn2}
                                                set {_em1.%{_match1-1}%} to {_match1-1}'s location
                                                set {_em.%{_match1-2}%} to {_match1-2}'s location
                                                execute console command "/effect %{_match1-1}% saturation 5 25"
                                                execute console command "/effect %{_match1-2}% saturation 5 25"
                                                set {eventmatch.%{_match1-1}%} to true
                                                set {eventmatch.%{_match1-2}%} to true
                                                set {eventopponent.%{_match1-1}%} to {_match1-2}
                                                set {eventopponent.%{_match1-2}%} to {_match1-1}
                                                loop {sumoplayers::*}:
                                                    send "{@prefix} &a&lStarting in... &c&l3" to loop-value
                                                    wait 1 second
                                                    send "{@prefix} &a&lStarting in... &c&l2" to loop-value
                                                    wait 1 second
                                                    send "{@prefix} &a&lStarting in... &c&l1" to loop-value
                                                    execute console command "/effect %{_match1-1}% resistance 9999 9 true"
                                                    execute console command "/effect %{_match1-2}% resistance 9999 9 true"
                                                    wait 1 second
                                                    send "{@prefix} &a&lGO!" to loop-value
                                                   
                                                # IDK WHAT TO PUT HERE
                                               
                                                wait 5 seconds
                                                teleport {sumoplayers::*} to {elobby}
                                                loop all players:
                                                    if size of {sumoplayers::*} > 0:
                                                        set {inevent.%loop-player%} to false
                                                set {eventsumo} to false
                                                set {eventhappening} to false
                                                clear {sumoplayers::*}

code_language.skript:
every 5 ticks:
    loop all players:
        if block at location of loop-players is water:
            if {eventmatch.%loop-player%} is true:
                set {eventmatch.%loop-player%} to false
                set {eventmatch.%{eventopponent.%loop-player%}%} to false
                wait 3 ticks
                loop {sumoplayers::*}:
                    send "&6%loop-player% &dhas been eliminated by &6%{eventopponent.%loop-player%}%" to loop-value
                set {inevent.%loop-player%} to false
                teleport {eventopponent.%loop-player%} to {espec}
                teleport loop-player to {espec}
                add {eventopponent.%loop-player%} to {_ml::*}
                remove loop-player from {sumoplayer::*}
                set {event.%loop-player%} to "none"

That ^^ is my code for now lol

no errors but complete fail LOL (also really unfinished)


pretty much need this all re-coded with help lol
 
code_language.skript:
                    wait 3 seconds
                                                set {_ml::*} to {sumoplayers::*}
                                                set {_match1-1} to random element out of {_ml::*}
                                                remove {_match1-1} from {_ml::*}
                                                set {_match1-2} to random element out of {_ml::*}
                                                remove {_match1-2} from {_ml::*}
                                                loop {sumoplayers::*}:
                                                    send "{@prefix} &6%{_match1-1}% &dvs &6%{_match1-2}%" to loop-value
                                                teleport {_match1-1} to {espawn1}
                                                teleport {_match1-2} to {espawn2}
                                                set {_em1.%{_match1-1}%} to {_match1-1}'s location
                                                set {_em.%{_match1-2}%} to {_match1-2}'s location
                                                execute console command "/effect %{_match1-1}% saturation 5 25"
                                                execute console command "/effect %{_match1-2}% saturation 5 25"
                                                set {eventmatch.%{_match1-1}%} to true
                                                set {eventmatch.%{_match1-2}%} to true
                                                set {eventopponent.%{_match1-1}%} to {_match1-2}
                                                set {eventopponent.%{_match1-2}%} to {_match1-1}
                                                loop {sumoplayers::*}:
                                                    send "{@prefix} &a&lStarting in... &c&l3" to loop-value
                                                    wait 1 second
                                                    send "{@prefix} &a&lStarting in... &c&l2" to loop-value
                                                    wait 1 second
                                                    send "{@prefix} &a&lStarting in... &c&l1" to loop-value
                                                    execute console command "/effect %{_match1-1}% resistance 9999 9 true"
                                                    execute console command "/effect %{_match1-2}% resistance 9999 9 true"
                                                    wait 1 second
                                                    send "{@prefix} &a&lGO!" to loop-value
                                                  
                                                # IDK WHAT TO PUT HERE
                                              
                                                wait 5 seconds
                                                teleport {sumoplayers::*} to {elobby}
                                                loop all players:
                                                    if size of {sumoplayers::*} > 0:
                                                        set {inevent.%loop-player%} to false
                                                set {eventsumo} to false
                                                set {eventhappening} to false
                                                clear {sumoplayers::*}

code_language.skript:
every 5 ticks:
    loop all players:
        if block at location of loop-players is water:
            if {eventmatch.%loop-player%} is true:
                set {eventmatch.%loop-player%} to false
                set {eventmatch.%{eventopponent.%loop-player%}%} to false
                wait 3 ticks
                loop {sumoplayers::*}:
                    send "&6%loop-player% &dhas been eliminated by &6%{eventopponent.%loop-player%}%" to loop-value
                set {inevent.%loop-player%} to false
                teleport {eventopponent.%loop-player%} to {espec}
                teleport loop-player to {espec}
                add {eventopponent.%loop-player%} to {_ml::*}
                remove loop-player from {sumoplayer::*}
                set {event.%loop-player%} to "none"

That ^^ is my code for now lol

no errors but complete fail LOL (also really unfinished)


pretty much need this all re-coded with help lol
But does this part work?
 
Status
Not open for further replies.