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

Projectile

Comments in 'Plugin Development' started by Vladislav, May 7, 2016.

  1. Vladislav
    Offline

    Vladislav New Member

    Joined:
    May 7, 2015
    Posts:
    17
    Minecraft User:
    CMEPTb5
    PHP:
        public function 
    (
    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("§aHit! You give $cfg->getNested(block1.money)");
         
    EconomyAPI::getInstance()->addMoney($player$cfg->getNested(block1.money));
    }
    }
    }
    Earn? If a player is shot with a bow and a projectile hit the block
  2. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    PHP:
    public function onShot(ProjectileHitEvent $ev){}
    What is Block1.x That's is false You Have A lot Error
  3. Vladislav
    Offline

    Vladislav New Member

    Joined:
    May 7, 2015
    Posts:
    17
    Minecraft User:
    CMEPTb5
    block1.x is the X coordinate of the block in which it is necessary to get an arrow
  4. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    Learn PHP
  5. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    public function
    (ProjectileHitEvent $event){
    $cfg = $this->getConfig();
    $arrow = $event->getEntity();
    if($arrow instanceof Arrow){
    $player = $arrow->shootingEntity; //Oops, my mistake.
    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("§aHit! You give $cfg->getNested(block1.money)");
    EconomyAPI::getInstance()->addMoney($player, $cfg->getNested(block1.money));
    }
    }
    }
    Last edited: May 8, 2016
    Primus likes this.
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    $player = $arrow->shootingEntity; It's correct. I agree with everything else
    minebuilder0110 likes this.
  7. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    have you readed latest section rules? xD

    Being unhelpful
    Posts such as "Learn PHP!", "Learn PocketMine!", or "Learn [x]!", although amusing, are generally unhelpful. If a post is deemed to be entirely unhelpful to the OP, it will be removed. This is due to the fact that the thread was created for he benefit of the OP and not for other users to laugh at someone's lack of knowledge. If the OP says something like "This isn't helpful", that is a good hint that what you are doing isn't helping.
    Ritch likes this.

Share This Page

Advertisement