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

The definition of the murderer and the one who died

Comments in 'Plugin Development' started by BlackJIeBPlayer, Jun 10, 2015.

  1. BlackJIeBPlayer
    Offline

    BlackJIeBPlayer New Member

    Joined:
    May 19, 2015
    Posts:
    18
    Minecraft User:
    BlackJIeB
    Hi, people. Now a whole week tormented with identifying and attacking the deceased.

    Code:
    Code:
    
    
    public function OffPvP(EntityDamageByEntityEvent $e){
    $cause = $e->getEntity()->getPlayer()->getName();
    if ($e->getEntity() instanceof Player) {
    if($e->getDamager() instanceof Player) {
    $killer = $e->getDamager()->getPlayer()->getName();
    
    
    if($this->isGameOn == 0){
    $e->setCancelled();
    
    }
    if($this->isGameOn == 1){
    if($this->whoIs[$cause] == 1){
    if($this->whoIs[$killer] == 1){
    $e->setCancelled();
    }
    } 
    Error:
    Code:
    2015-06-09 23:01:34 [NOTICE] InvalidArgumentException: "Argument 1 passed to eddir\microBattle::OffPvP() must be an instance of pocketmine\event\entity\EntityDamageByEntityEvent, instance of pocketmine\event\entity\EntityDamageEvent given, called in phar:///home/gs2004/PocketMine-MP.phar/src/pocketmine/plugin/MethodEventExecutor.php on line 36 and defined" (E_RECOVERABLE_ERROR) in "/microBattle [OW]/src/eddir/microBattle" at line 1201
    2015-06-09 23:01:34 [CRITICAL] "Could not pass event 'pocketmine\event\entity\EntityDamageEvent' to 'microBattle v0.1 beta for OW': Argument 1 passed to eddir\microBattle::OffPvP() must be an instance of pocketmine\event\entity\EntityDamageByEntityEvent, instance of pocketmine\event\entity\EntityDamageEvent given, called in phar:///home/gs2004/PocketMine-MP.phar/src/pocketmine/plugin/MethodEventExecutor.php on line 36 and defined on eddir\microBattle
    Maybe somebody knows how to do?
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Handle EntityDamageEvent and check if event is instanceof EntityDamageByEntityEvent in the handler.
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    PHP:
    public function onHurt(EntityDamageEvent $e){
                if(
    $e instanceof EntityDamageByEntityEvent){
                    if(
    $e->getDamager() instanceof Player && $e->getEntity() instanceof Player){
                              
    $killer $e->getDamager()->getPlayer()->getName();
                              
    $cause $e->getEntity()->getPlayer()->getName();
                              if(
    $this->isGameOn == 0){
                                            
    $e->setCancelled();

                              }
                              if(
    $this->isGameOn == 1){
                                          if(
    $this->whoIs[$cause] == 1){
                                                            if(
    $this->whoIs[$killer] == 1){
                                                                       
    $e->setCancelled();
                                                             }
                                          }
                              }
            }
    }
    PEMapModder and BlackJIeBPlayer like this.
  4. BlackJIeBPlayer
    Offline

    BlackJIeBPlayer New Member

    Joined:
    May 19, 2015
    Posts:
    18
    Minecraft User:
    BlackJIeB
    wow, works perfectly, thank you very much :p
    PEMapModder and Creeperface like this.

Share This Page

Advertisement