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

handling pvp (with bow)

Comments in 'Plugin Development' started by dxm_hippie, Jun 8, 2015.

  1. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    I dont see why this code dont work to set a player on fire when hit by a arrow ):


    PHP:
    Public function onArrowHit(ProjectileHitEvent $ev) {
        
    $victim $ev->getEntity();
        
    $shooter $victim->getLastDamageCause();
        if(
    $shooter instanceof EntityDamageByEntityEvent){
                   
    $shooter $shooter->getDamager();
        if (
    $shooter instanceof Player) {
                      
                   if(
    $shooter->hasPermission("power.tools")){
                   
    $victim->setOnFire();
                   }
                   }
                   else{
                       return 
    false;
                   }
                   }
                   else{
                       return 
    false;
                   }
    }
    }
  2. SpiderPig
    Offline

    SpiderPig Active Member

    Joined:
    Sep 21, 2013
    Posts:
    128
    Minecraft User:
    SpiderPig
    You need to track the arrow from the moment it's shot till the minute it lands on the entity.
    You should use https://github.com/PocketMine/Pocke...cketmine/event/entity/EntityShootBowEvent.php to check when the arrow is shot and then you should store the variables. Until the EntityDamageByEntityEvent is called. Once that is called you should check the information with the variables from before.
    dxm_hippie likes this.
  3. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    That sounds more confusing than i hoped lol im a noobie at php :p i have no idea how to "track" a arrow..theres nothing like entityHitByArrow event? lol
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Interesting point: what if the player left the server before the arrow hit?
    Also, ProjectileHitEvent is fired before EntityDamageEvent is fired, and without EntityDamageEvent being fired, calling getLastDamageCause is useless.
    You should use $projectile->shootingEntity.
    SpiderPig likes this.

Share This Page

Advertisement