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

Task ticks start from 1 not 20

Discussion in 'Development' started by Kenn Fatt, Mar 22, 2018.

  1. Kenn Fatt

    Kenn Fatt Slime

    Messages:
    82
    GitHub:
    kennfatt
    Why task start run from 1 and then 21, 41, and so on?

    Should'nt it run like from 0 or 20, then 40, 60, 80, and so on?
    I'm just trying to make some calculation with $currentTicks and Math method there.
     
  2. di2134876

    di2134876 Spider Jockey

    Messages:
    29
    GitHub:
    dk1234987
    Can you give more explanation?
     
  3. Herojhjh

    Herojhjh Silverfish

    Messages:
    20
    GitHub:
    herojhjh
    20 tick is 1 second
     
  4. di2134876

    di2134876 Spider Jockey

    Messages:
    29
    GitHub:
    dk1234987
    :facepalm::facepalm:
     
  5. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    no code no help
    make sure you set it at construct
    make sure you arent new-ing the instance so it reset
     
  6. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    1. Plugins are not guaranteed to start at server start. They may start when the server has been running for a while.
    2. When the server is starting up, the tick is 0. When a task is scheduled, it is only checked to be run on the first tick (that is, tick 1).
    3. If you schedule a repeating task when the server is already running (tick != 0), scheduling a repeating task will execute the task in the same tick (potentially resulting in an infinite loop).
     
    Kenn Fatt likes this.
  7. Kenn Fatt

    Kenn Fatt Slime

    Messages:
    82
    GitHub:
    kennfatt
    This is what I wanted to read. Thanks.
     
  8. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Another way of viewing it is to treat ticks as "PocketMine timestamps". Just like when you work with Unix timestamps, you are only interested in the current timestamp and the difference of some stored timestamp from the current timestamp, and you won't really care about when the Unix timestamp epoch was dated.
     
  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.