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

PlayerMoveEvent Troubles

Comments in 'Plugin Development' started by Tethered_, Jun 1, 2015.

  1. Tethered_
    Offline

    Tethered_ Active Member Plugin Developer

    Joined:
    Jun 24, 2014
    Posts:
    178
    Plugins:
    2
    Minecraft User:
    Frostbyte58
    I'm trying to trigger something when a player reaches the y coordinate of 23 so I have this code:

    PHP:
    public function onPlayerMove(PlayerMoveEvent $pme)
        {
            if(
    self::$isRunning)
            {
                if(
    $pme->getPlayer()->getFloorY() >= 23);
                {
                    
    $this->stop($pme->getPlayer()->getName());
                }
            }
        }
    stop() merely broadcasts the name of the player to the server

    $isRunning is triggered as soon as the player is teleported to coordinates (147, 4, 95)

    As soon as isRunning is set to true, stop() is fired instantly even though the player is at y coordinate 4 and I have absolutely no idea why. Any thoughts?
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Try <= instead of >=
  3. SpiderPig
    Offline

    SpiderPig Active Member

    Joined:
    Sep 21, 2013
    Posts:
    128
    Minecraft User:
    SpiderPig
    Try this.
    PHP:
    public function onPlayerMove(PlayerMoveEvent $pme)
        {
            if(
    self::$isRunning)
            {
                if(
    $pme->getPlayer()->getFloorY() >= 23){
                    
    $this->stop($pme->getPlayer()->getName());
                }
            }
        }
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Did you even change anything?
  5. Tethered_
    Offline

    Tethered_ Active Member Plugin Developer

    Joined:
    Jun 24, 2014
    Posts:
    178
    Plugins:
    2
    Minecraft User:
    Frostbyte58
    how is that any different?
    HotFireyDeath and iJoshuaHD like this.
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    There is no difference. Change >= to <=
  7. Tethered_
    Offline

    Tethered_ Active Member Plugin Developer

    Joined:
    Jun 24, 2014
    Posts:
    178
    Plugins:
    2
    Minecraft User:
    Frostbyte58
    It did the same thing
  8. SpiderPig
    Offline

    SpiderPig Active Member

    Joined:
    Sep 21, 2013
    Posts:
    128
    Minecraft User:
    SpiderPig
    You added a ; after the If so it will jump the line once finished.
    PEMapModder likes this.
  9. Tethered_
    Offline

    Tethered_ Active Member Plugin Developer

    Joined:
    Jun 24, 2014
    Posts:
    178
    Plugins:
    2
    Minecraft User:
    Frostbyte58
    Oh my God, I spent an hour and a half trying to figure that out... Thank you a ton. I can't believe I did that.
  10. SpiderPig
    Offline

    SpiderPig Active Member

    Joined:
    Sep 21, 2013
    Posts:
    128
    Minecraft User:
    SpiderPig
    Ok I did correct a couple of posts back but you didn't see the correction.
  11. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    xD lol '' Did you even change something? ''
    PEMapModder likes this.
  12. Tethered_
    Offline

    Tethered_ Active Member Plugin Developer

    Joined:
    Jun 24, 2014
    Posts:
    178
    Plugins:
    2
    Minecraft User:
    Frostbyte58
    Yeah both me and @CraftYourBukkit didn't notice any change lmao
    SpiderPig likes this.
  13. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Yea lol @SpiderPig you could have add a comment! xD
  14. SpiderPig
    Offline

    SpiderPig Active Member

    Joined:
    Sep 21, 2013
    Posts:
    128
    Minecraft User:
    SpiderPig
    It was late lol.
  15. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    XD

Share This Page

Advertisement