Arena countdown teleport system

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

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

SoMuchWessel

Active Member
Apr 3, 2017
147
3
18
47
Hey guys, Im working on a arena like Skript. Players click on a sign named Blue and Red. If they choose Blue, they will go into team blue. I also have a countdown system like this:
code_language.skript:
command /startsandbox:
    trigger:
        if {sandbox.countdown} is false:
            set {sandbox.countdown} to true
            loop all players:
                loop-player has permission "sandbox.chat":
                    if {%loop-player-1%.team} = 1: #team blue
                        send "&bEnough people are ready!" to loop-player
                        wait 1 second
                        send "&b5.." to loop-player
                        wait 1 second
                        send "&b4.." to loop-player
                        wait 1 second
                        send "&b3.." to loop-player
                        wait 1 second
                        send "&b2.." to loop-player
                        wait 1 second
                        send "&b1.." to loop-player
                        wait 1 second
                        make loop-player-1 execute command "/warp bsand"
                        set {sandbox.game.started} to 1

                    else if {%loop-player-1%.team} = 2: #team red
                        send "&bEnough people are ready!" to loop-player
                        wait 1 second
                        send "&b5.." to loop-player
                        wait 1 second
                        send "&b4.." to loop-player
                        wait 1 second
                        send "&b3.." to loop-player
                        wait 1 second
                        send "&b2.." to loop-player
                        wait 1 second
                        send "&b1.." to loop-player
                        wait 1 second
                        make loop-player-1 execute command "/warp rsand"
                        set {sandbox.game.started} to 1

But what now happens is that if you are with 2 people in the game, First one player gets the countdown and get teleported, and after that another one. But what i want is that everyone is teleported at the same time, everyone from the blue team and everyone from the red team. Can you guys help me out?
 
Well, you may want to rewrite that system because it's really ineficient and wouldn't let you want you want to do. As it seems, you're a newbie at Skript so I'll leave some tricks here:

  • List variables are a lot better than single variables, instead of write:
code_language.skript:
set {sandbox.cooldown} to true
it's better to do:
code_language.skript:
set {sandbox::cooldown} to true
why? Because if the game finished you should delete those variables, with single variables you would do:
code_language.skript:
delete {sandbox.cooldown} and {sandbox.game.started}
but with a list variables it's as simple as do:
code_language.skript:
delete {sandbox::*}
other benefit from them is that you can iterate through them, which isn't possible with single variables. Basically, this:
code_language.skript:
loop {sandbox::*}:
    send "%loop-value% - %loop-index%"
  • Other thing I see is that you're doing the following:
    code_language.skript:
    set {%player%.team} to whatever
    Which is something you shouldn't do because, first of all, that's a horrible variable naming and even Skript throws a warning about that, and the another reason is that you could do it better with list variables, for example:
code_language.skript:
add player to {sandbox::team::red::*}
and then do:
code_language.skript:
send "<light blue>Enough players are ready!" to {sandbox::team::red::*} and {sandbox::team::blue::*}
loop 5 times:
    send "<light blue>%6 - loop-num%..." to {sandbox::team::red::*} and {sandbox::team::blue::*}
    wait 1 second
teleport {sandbox::team::blue::*} to {sandbox::team::startLocation::red} #you would have to set these variables.
teleport {sandbox::team::red::*} to {sandbox::team::startLocation::blue}

Now, regarding your issue, you should set two variables with the start location of every team as I said above and then teleport them to it.
 
Well, you may want to rewrite that system because it's really ineficient and wouldn't let you want you want to do. As it seems, you're a newbie at Skript so I'll leave some tricks here:

  • List variables are a lot better than single variables, instead of write:
code_language.skript:
set {sandbox.cooldown} to true
it's better to do:
code_language.skript:
set {sandbox::cooldown} to true
why? Because if the game finished you should delete those variables, with single variables you would do:
code_language.skript:
delete {sandbox.cooldown} and {sandbox.game.started}
but with a list variables it's as simple as do:
code_language.skript:
delete {sandbox::*}
other benefit from them is that you can iterate through them, which isn't possible with single variables. Basically, this:
code_language.skript:
loop {sandbox::*}:
    send "%loop-value% - %loop-index%"
  • Other thing I see is that you're doing the following:
    code_language.skript:
    set {%player%.team} to whatever
    Which is something you shouldn't do because, first of all, that's a horrible variable naming and even Skript throws a warning about that, and the another reason is that you could do it better with list variables, for example:
code_language.skript:
add player to {sandbox::team::red::*}
and then do:
code_language.skript:
send "<light blue>Enough players are ready!" to {sandbox::team::red::*} and {sandbox::team::blue::*}
loop 5 times:
    send "<light blue>%6 - loop-num%..." to {sandbox::team::red::*} and {sandbox::team::blue::*}
    wait 1 second
teleport {sandbox::team::blue::*} to {sandbox::team::startLocation::red} #you would have to set these variables.
teleport {sandbox::team::red::*} to {sandbox::team::startLocation::blue}

Now, regarding your issue, you should set two variables with the start location of every team as I said above and then teleport them to it.

Thanks for your respond. Yes i am new at Skript and i know it is a bit inefficient, but i understand the single variables, so thats why i used them so much.
I dont really understand list variables, all i do in my 600+ lines skript is setting variables to 0 or 1, or true or false.
I think its going to be hard to kinda rewrite the whole thing to use list variables
[doublepost=1494967681,1494946462][/doublepost]Is there any way to do it with single variables?
 
Thanks for your respond. Yes i am new at Skript and i know it is a bit inefficient, but i understand the single variables, so thats why i used them so much.
I dont really understand list variables, all i do in my 600+ lines skript is setting variables to 0 or 1, or true or false.
I think its going to be hard to kinda rewrite the whole thing to use list variables
[doublepost=1494967681,1494946462][/doublepost]Is there any way to do it with single variables?
Send the full script in a here or in a PM if you want, I'll help you with the recode :emoji_thumbsup:
 
Status
Not open for further replies.