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

help! Arrow

Comments in 'Plugin Development' started by Vladislav, Apr 21, 2016.

  1. Vladislav
    Offline

    Vladislav New Member

    Joined:
    May 7, 2015
    Posts:
    17
    Minecraft User:
    CMEPTb5
    How to check if an arrow fell to the coordinates, then something happened? EntityShootsBowEvent
  2. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    PHP:
    if($arrow->== $x && $arrow->== $y && $arrow->== $z):
    // code
    endif;
  3. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Use ProjectileHitEvent and check the position of the arrow.
    HotFireyDeath and Primus like this.
  4. Vladislav
    Offline

    Vladislav New Member

    Joined:
    May 7, 2015
    Posts:
    17
    Minecraft User:
    CMEPTb5
    $arrow = $event->getProjectile();?
  5. Vladislav
    Offline

    Vladislav New Member

    Joined:
    May 7, 2015
    Posts:
    17
    Minecraft User:
    CMEPTb5
    Can you give a code, please?
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    public function onHit(ProjectileHitEvent $e){
       
    $pos $e->getEntity()->getPosition();
    }
    HotFireyDeath and Nawaf_Craft1b like this.
  7. Vladislav
    Offline

    Vladislav New Member

    Joined:
    May 7, 2015
    Posts:
    17
    Minecraft User:
    CMEPTb5
    As players get? who shot
  8. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    What? If you want the player who shot the Arrow:
    PHP:
    $arrow $event->getEntity();
    if(
    $arrow instanceof Arrow){
    $player $arrow->shootingEntity;
    }
    in ProjectileHitEvent, white $event is the event
    HotFireyDeath likes this.
  9. Vladislav
    Offline

    Vladislav New Member

    Joined:
    May 7, 2015
    Posts:
    17
    Minecraft User:
    CMEPTb5
    Thank :)
  10. Vladislav
    Offline

    Vladislav New Member

    Joined:
    May 7, 2015
    Posts:
    17
    Minecraft User:
    CMEPTb5
    Don't work :(
    PHP:
          public function onHit(ProjectileHitEvent $event){
        
    $cfg $this->getConfig();
        
    $arrow $event->getEntity();
          if(
    $arrow instanceof Arrow){
           
    $player $arrow->shootingEntity;
                if(
    $player instanceof Player){
             if(
    $arrow->getPosition->getX() == $cfg->getNested(block1.x) && $arrow->getPosition->getY() == $cfg->getNested(block1.y) && $arrow->getPosition->getX() == $cfg->getNested(block1.z))
    {
        
    $player->sendMessage("Wow! You give $cfg->getNested(block1.money)");
         
    EconomyAPI::getInstance()->addMoney($player$cfg->getNested(block1.money));
    }
    Last edited: Apr 22, 2016
  11. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    There are many syntax errors, why don't you learn php at first?
  12. Vladislav
    Offline

    Vladislav New Member

    Joined:
    May 7, 2015
    Posts:
    17
    Minecraft User:
    CMEPTb5
    This is the main part of the code, the plugin itself works, but does not execute code.

Share This Page

Advertisement