Wait x seconds to do things, where X is the distance between two points.

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

Lummox

Member
Jan 29, 2017
28
0
1
42
I am unable to find out how to solve this, I would appreciate if you can help me.

I want to calculate the distance between two points and divide it by 3.5, I do this with:

code_language.skript:
set {palomas.distancia.%player%} to a rounded distance between the player and {palomas.destinos::%{_destino}%} / 3.5

Then I want to do the following, you have to wait X amount of seconds, this "X" is the resultant number of the operation that calculates the distance between the two points.

For example, if the distance between the two points is 5000 blocks, you would have to wait 5000/3 = 1666 seconds for the script to continue.

The part of code that I have made and does not work is this:

code_language.skript:
set {palomas.distancia.%player%} to a rounded distance between the player and {palomas.destinos::%{_destino}%} / 3.5
            set {_distancia} to {palomas.distancia.%player%} parsed as number
            set {palomas.tiempo.%player%} to now
            wait %{_distancia}% seconds
            if difference between {palomas.tiempo.%player%} and now is greater than {palomas.distancia.%player%} seconds:
                add {_mensaje} to {palomas.buzon.%{_destino}%::*}
            stop

This part of the code does not seem to work (gives error):

code_language.skript:
            wait %{_distancia}% seconds
            if difference between now and {palomas.tiempo.%player%} is greater than %{_distancia}% seconds:

How can I do this?

Thanks in advance :emoji_wink:
 
the wait effect only accept timespans, not numbers, you have to parse it to a timespan:

code_language.skript:
set {_wait} to "%{palomas.distancia.%player%}% seconds" parsed as timespan
wait {_wait}
 
Works perfect, thanks !.

Just one more question, in case the action is not completed because during the wait the server is going to restart ... is there any way to cancel the restart until the action is completed?
 
Status
Not open for further replies.