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

Stopwatch

Comments in 'Plugin Development' started by WitherTube, Dec 21, 2015.

  1. WitherTube
    Offline

    WitherTube New Member

    Joined:
    Dec 21, 2015
    Posts:
    44
    Minecraft User:
    Wither_Tube
    Hey
    i want to add to my Plugin a Stopwatch which records the time for example for a Race and output at the end the Time.Can you help me please and explain it.

    Thankss :D.
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    time();
    How you are using it, that's your decision.
    WitherTube likes this.
  3. WitherTube
    Offline

    WitherTube New Member

    Joined:
    Dec 21, 2015
    Posts:
    44
    Minecraft User:
    Wither_Tube
    I need to get the time between two moments. For example the time between the beginning of a race and the end of it.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    time() (https://PHP.net/time) returns the number of seconds from 1970-1-1 to the current time (the time the code is run).

    If you record the time() when the race starts, then record the time() when the race ends, then subtract end by start, it is the number of seconds elapsed.
  5. WitherTube
    Offline

    WitherTube New Member

    Joined:
    Dec 21, 2015
    Posts:
    44
    Minecraft User:
    Wither_Tube
    Can you mkae me please ana example ??
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    // Race starts
    $beginning time();

    //Race is running...

    //Race end
    $end time();

    //Time from $beginning to $end(in sec):
    $time $end $beginning;
    Last edited: Dec 22, 2015
    WitherTube likes this.

Share This Page

Advertisement