Simple Queue Plugin + Random Teleporting

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

Fatboys

Member
Mar 8, 2017
23
1
0
I have wrote the simple basics of my beginner queue skript where players can join a queue and when enough players are in that queue, it will begin a countdown and teleport all players somewhere.
My problem is that all the players teleport to the same spot when I want them to be teleported to different areas within a certain location.
Here is my code.
code_language.skript:
on script load:
    set {queue1} to 0
    delete {queue::*}

command /reset:
    trigger:
        delete {queue::*}
        set {queue1} to 0

command /setloc:
    trigger:
        set {spawn} to location of player
        
command /queue [<text="check">]:
    usage: You can either use &c/queue join &for &c/queue leave
    trigger:
        if arg-1 is "check":
            send "&cThere are &e%{queue1}%/16 &cplayers in the queue!" to player
        if arg-1 is "join":
            if {queue1} >= 8:
                execute console command "/queue start"
            if {queue1} >= 16:
                send "&cThe queue is full!" to player
            else if "%{queue::*}%" contains "%player%":
                send "&cYou are already in the queue!" to player
            else:
                add 1 to {queue1}
                add "%player%" to {queue::*}
                set {queue.%player%} to 1
                broadcast "&cThere are now &e%{queue1}%/16 &cplayers in the queue!"
        if executor is console:
            if arg-1 is "start":
                if {queue1} >= 8:
                    broadcast "&eThe match is about to start!"
                    broadcast "&cThe match will begin in &e15 seconds.."
                    wait 10 seconds
                    broadcast "&cThe match will begin in &e5 seconds.."
                    wait 1 seconds
                    broadcast "&cThe match will begin in &e4 seconds.."
                    wait 1 seconds
                    broadcast "&cThe match will begin in &e3 seconds.."
                    wait 1 seconds
                    broadcast "&cThe match will begin in &e2 seconds.."
                    wait 1 seconds
                    broadcast "&cThe match will begin in &e1 seconds.."
                    wait 1 second
                    broadcast "&eTeleporting players.."
                    loop {queue::*}:
                        teleport loop-value parsed as player to {spawn}
                    delete {queue::*}
                    delete {queue1}
                else:
                    send "&cNot enough players to start!" to player
        if arg-1 is "leave":
            if {queue.%player%} is 1:
                remove 1 from {queue1}
                send "&cYou have been removed from the queue!"
                broadcast "&cThere are now &e%{queue1}%/16 &cplayers in the queue!"
                remove "%player%" from {queue::*}
            else:
                send "&cYou are not currently in a queue!"
command /test:
    trigger:
        send "%{queue::*}%" to player
        send "%{queue1}%" to player
        
command /test2:
    trigger:
        add 1 to {queue1}
        broadcast "&cThere are now &e%{queue1}%/16 &cplayers in the queue!"
        
on death:
    if {queue.%player%} is 1:
        remove 1 from {queue1}
        set {queue.%player%} to 0
        if {queue1} is 0:
            broadcast "&cThe game is now over!"
            broadcast "&cUse &e/queue join &cto join the next queue!"

on join:
    set {queue.%player%} to 0

The code is very basic right now, being limited to only one queue. I thought it would be a good idea to start with the easy stuff and continue later on.

The part where it teleports all people is this section.

code_language.skript:
                    loop {queue::*}:
                        teleport loop-value parsed as player to {spawn}

How can I change it to teleport each loop-value to a random location within a certain area?
 
You can generate random numbers and use them as coordinates :emoji_slight_smile: if you want to spawn the player between the x coordinate 1 and 100 you just generate a random number between 1 and 100. Same with the X coordinate and teleport the player to the generated coordinates :emoji_wink:
 
@Fatboys
Example of spawnpoints:
code_language.skript:
command /set [<number>]:
    trigger:
        set {minigame::spawnpoints::%arg-1%} to location of player
    
loop {minigame::players::*}:
    teleport loop-value to location of {minigame::spawnpoints::%loop-index%}

Examples of cooldown:
code_language.skript:
set {_cooldown} to 60
while {_cooldown} is more than 0:
    broadcast "&9Cooldown&8: &c%{_cooldown}%"
    remove 1 from {_cooldown}
    wait 1 second
   
set {_cooldown} to 60  
loop 60 times:
    broadcast "&9Cooldown&8: &c%{_cooldown}%"
    remove 1 from {_cooldown}
    wait 1 second
 
Last edited by a moderator:
Status
Not open for further replies.