pget_time returning strange values

Discussion in 'CommandHelper' started by malon, Sep 23, 2017.

  1. malon

    malon Member

    From my understanding, pget_time is only supposed to return an integer between 0 and 24000. I'm getting numbers in the 150,000+ range.

    I used essentials to change the server time (/time set whatever) then I would run my /test3 command which prints out the current time as CommandHelper sees it.

    Screenshot:
    https://imgur.com/a/Sf6gs

    Code:
    PHP:
    test3:/test3 = >>>

        msg(color(RED).pget_time().' <-- CommandHelper time')

    <<<
  2. PseudoKnight

    PseudoKnight Well-Known Member

    This simply returns what Bukkit gives us. Our documentation seems to be wrong, though. It will NOT only return 0-24000. (similarly, set_ptime() is not modulo scaled) In this case, that particular player seems to have a relative time of 72000 for some reason.
  3. malon

    malon Member

    I'm not sure I understand how to solve my problem. What is "relative time?" How do I fix the offset? What are the values I need to check to see if it's night time or day time?
  4. PseudoKnight

    PseudoKnight Well-Known Member

    At some point your scripts (or another plugin) set the player's time. (Note that this is NOT the world time. It's meant to be used for setting only what that particular client sees.) When setting the player time, it can be set to be "relative" to the world time. So the player's time will continue to move along with the world's time, just offset, as seen when you changed the world time to later. Or if the world time is frozen, the player's time will also remain frozen. If the player time is not set to be "relative", that too would make time appear to be frozen for that player.

    If you didn't realize any of this, it's possible you meant to use world time, not player time.

    To fix the offset, I think you'd just set the player time to the world time with the relative argument as true. I think it should fix itself the next time they relog, though.
  5. malon

    malon Member

    Thank you very much for making that clear to me. I had no idea each player had their own clock, but that makes a lot of sense now that you explain it. Thank you very much, all is working well!