Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Time intervals

Comments in 'Plugin Development' started by xFlare, Nov 27, 2014.

  1. xFlare
    Offline

    xFlare Active Member Plugin Developer

    Joined:
    Sep 28, 2014
    Posts:
    199
    Plugins:
    1
    Minecraft User:
    xFlare
    How can I add a wait time limit. For example I'm used to the "intsleep ( int $seconds )" functions in php. I don't know how to do something like this in plugins

    //run code

    wait time limit here

    //run this code after time is up
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Make a schedule. In PHP structure, this code:
    PHP:
    Some_code();
    Some_else_code();
    Some_more_code();
    Between some_code() and some_more_code(), whatever you put in for some_else_code(), it must be the code inside some_else_code() that is run and nothing else inside that thread.

    This means, you cannot call a function to reserve the later code to be run later unless you pause the server (sleep()). But that will hibernate the whole server and clients will think that the server has closed/crashed instead.
    Xenturio likes this.
  3. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Yes. Anyway, you must use a schedule unless your operation is thread-safe.

Share This Page

Advertisement