1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved How to wait x before running some code

Discussion in 'Development' started by MalakasPlayzMCPE, May 29, 2018.

  1. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    I know sleep($timeInSeconds); does that but it stops all the server tasks. I know I have schedule a repeating task for that but I want something like wait($time); (idk if this exists). If there is no method for that, how to run a code x and wait 1 second to run a code y without using config?
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    schedule a delayed plugin task for 1 second
    if you wanna wait one second
     
  3. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    20 ticks*
    My problem is not there. I searched and there is no wait();
    I want to execute a code x, wait one second and execute a code y. You know, right?
     
  4. Eduardo

    Eduardo Baby Zombie

    Messages:
    100
    GitHub:
    xBeastMode
    Execute your first code then schedule a delayed task to execute your next code after x seconds.
     
  5. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Thanks, lol.
     
  6. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    if you are a developer you know 1 second = 20 ticks and that shouldnt need to even be mentioned

    if i said 2 second but the argument is tick and you know 1 second = 20 ticks you can simply multiply 20 by 2
     
  7. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Ok, lol. I thought you didn't know we use ticks, sorry.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.