How to make a spawn teleport taking 5 seconds but detecting any movement during the time.

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

d1axowy

Member
Apr 15, 2022
1
0
1
I created a script that when someone types /spawn it teleports the player after 5 seconds, but during the time, the player has a blindness effect.
Everything is working fine, but what I need is help with making it detect the player's movement, and when he moves during the 5 seconds, the event of teleporting him to spawn gets cancelled and the blindness effect is removed. I know there are several other posts about it, but no solutions helped me exactly.
Could anyone re-code the script with the move detection thing?

Here is my script ( the lines with the send command is Polish)
https://pastebin.com/xAvdUsNP\
 
I created a script that when someone types /spawn it teleports the player after 5 seconds, but during the time, the player has a blindness effect.
Everything is working fine, but what I need is help with making it detect the player's movement, and when he moves during the 5 seconds, the event of teleporting him to spawn gets cancelled and the blindness effect is removed. I know there are several other posts about it, but no solutions helped me exactly.
Could anyone re-code the script with the move detection thing?

Here is my script ( the lines with the send command is Polish)
https://pastebin.com/xAvdUsNP\
Doing something like this
But be aware that any movement also counts cámara movement.
Code:
On any movement:
    Set {don't move %player%} to true
Command /spawn:
    Trigger:
        Delete {don't move %player%}
        Set {_count down} to 5
        While {_count down} exists:
            Message "teleporting you in %{_count down}% seconds. Don't move.
            If {don't move %player%} is not true:
                If {_count down} is equal to 0:
                    Teleport the player to {spawn}
                    Exit loop
                Else:
                    Wait 1 second
            Else:
                 Message "Teleport cancelled you move"
                 Exit loop
 
Doing something like this
But be aware that any movement also counts cámara movement.
Code:
On any movement:
    Set {don't move %player%} to true
Command /spawn:
    Trigger:
        Delete {don't move %player%}
        Set {_count down} to 5
        While {_count down} exists:
            Message "teleporting you in %{_count down}% seconds. Don't move.
            If {don't move %player%} is not true:
                If {_count down} is equal to 0:
                    Teleport the player to {spawn}
                    Exit loop
                Else:
                    Wait 1 second
            Else:
                 Message "Teleport cancelled you move"
                 Exit loop

Would not recommend doing this. Rather use a while loop, like:
Code:
command /spawn [<text>]:
    trigger:
        send "please wait 5 seconds"
        set {_left} to 6
        set {_loc} to location of player
        while {_left} is more than 0:
            if location of player is {_loc}:
                remove 1 from {_left}
                wait 1 second
            else:
                send "you moved"
                stop
 
Status
Not open for further replies.