Random respawn

  • 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.
Code:
command /setspawn <integer>:
    trigger:
        set {spawnpoint::%arg-1%} to player's location

command /spawn:
    trigger:
        loop {spawnpoint::*}:
            chance of 25%:
                #do smth
 
Code:
command /setspawn <integer>:
    trigger:
        set {spawnpoint::%arg-1%} to player's location

command /spawn:
    trigger:
        loop {spawnpoint::*}:
            chance of 25%:
                #do smth
I mean random spawn locations. Like without /spawn when u die u just respawn random in one of those random 4 locations
 
probably a better way of doing it would be to use:

Code:
command /setspawn:
    trigger:
        add event-player's location to {spawnpoint::*}

command /unsetspawn:
    trigger:
        loop indexes of {spawnpoint::*}:
            if distance between event-player's location and {spawnpoint::%loop-value%} < 2:
                remove {spawnpoint::%loop-value%} from {spawnpoint::*}

command /unsetallspawn:
    trigger:
        clear {spawnpoint::*}

on respawn:
    teleport event-player to a random location out of {spawnpoint::*}
that way you can set as many spawns as you want, and remove them if needed. or even reset them all with unsetallspawn

might want to add some permissions so that not every player can set and unset your spawns.
 
probably a better way of doing it would be to use:

Code:
command /setspawn:
    trigger:
        add event-player's location to {spawnpoint::*}

command /unsetspawn:
    trigger:
        loop indexes of {spawnpoint::*}:
            if distance between event-player's location and {spawnpoint::%loop-value%} < 2:
                remove {spawnpoint::%loop-value%} from {spawnpoint::*}

command /unsetallspawn:
    trigger:
        clear {spawnpoint::*}

on respawn:
    teleport event-player to a random location out of {spawnpoint::*}
that way you can set as many spawns as you want, and remove them if needed. or even reset them all with unsetallspawn

might want to add some permissions so that not every player can set and unset your spawns.
But I need something that when someone dies, he will have to press on something in a gui, then respawn in one of the 4 coordinates that I set.
 
probably a better way of doing it would be to use:

Code:
command /setspawn:
    trigger:
        add event-player's location to {spawnpoint::*}

command /unsetspawn:
    trigger:
        loop indexes of {spawnpoint::*}:
            if distance between event-player's location and {spawnpoint::%loop-value%} < 2:
                remove {spawnpoint::%loop-value%} from {spawnpoint::*}

command /unsetallspawn:
    trigger:
        clear {spawnpoint::*}

on respawn:
    teleport event-player to a random location out of {spawnpoint::*}
that way you can set as many spawns as you want, and remove them if needed. or even reset them all with unsetallspawn

might want to add some permissions so that not every player can set and unset your spawns.

Yes but how do I set the coords where to respawn

have you read the script?
with my script you can just use /setspawn to add it,
/unsetspawn to remove all spawnpoints within 2 blocks, and /unsetallspawn to remove all spawnpoints.

with his code you had to do /setspawn <1-4> to set the spawn with index number 1-4 (you would have to take both his code snippets)[/QUOTE]
 
Last edited:
have you read the script?
with my script you can just use /setspawn to add it,
/unsetspawn to remove all spawnpoints within 2 blocks, and /unsetallspawn to remove all spawnpoints.

with his code you had to do /setspawn <1-4> to set the spawn with index number 1-4 (you would have to take both his code snippets)
Wait I am stupid. Very stupid. I just realised
 
almost pressed the agree button on your comment.
this post should be marked as solved.
There is still a problem. I am not respawning to any of them. I did /setspawn 1,2,3,4 in different locations.
[doublepost=1621699362,1621699253][/doublepost]
There is still a problem. I am not respawning to any of them. I did /setspawn 1,2,3,4 in different locations.
Also is there any way to add the respawn into a gui ? Like when u respawn u see a button in the gui to press and respawn to one of the random locations. I need that with the sleeping bag. To count in that respawn gui when u have placed a sleeping bag and also a button for the respawn in one of those random locations
 
Please upload your entire code
Code:
command /setspawn:
    trigger:
        add event-player's location to {spawnpoint::*}
 
command /unsetspawn:
    trigger:
        loop indexes of {spawnpoint::*}:
            if distance between event-player's location and {spawnpoint::%loop-value%} < 2:
                remove {spawnpoint::%loop-value%} from {spawnpoint::*}
 
command /unsetallspawn:
    trigger:
        clear {spawnpoint::*}
 
on respawn:
    teleport event-player to a random location out of {spawnpoint::*}
I am not respawning random even that I set the /setspawn 1,2,3,4
 
Try this and clear all spawn points and set new ones
Code:
command /setspawn:
    trigger:
        add location of player to {spawnpoint::*}
 
command /unsetspawn:
    trigger:
        loop indexes of {spawnpoint::*}:
            if distance between player's location and {spawnpoint::%loop-value%} < 2:
                remove {spawnpoint::%loop-value%} from {spawnpoint::*}
 
command /unsetallspawn:
    trigger:
        clear {spawnpoint::*}
 
on respawn:
    teleport player to a random location out of {spawnpoint::*}
 
Wdym with "same location"? Do you respawn at the same location every time or at the default minecraft spawn point?

Try adding a delay
Code:
on respawn:
    wait 0.5 seconds
    teleport player to a random location out of {spawnpoint::*}
 
Status
Not open for further replies.