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

Why doesnt work?

Comments in 'Plugin Development' started by DarkFlameFraYT, Jul 17, 2015.

  1. DarkFlameFraYT
    Offline

    DarkFlameFraYT New Member

    Joined:
    Jul 9, 2015
    Posts:
    16
    Minecraft User:
    DarkFlameFraYT
    Code
    - i'm noob :p
    PHP:
    <?php

    namespace DarkFraYT\BowPvP;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\level\level;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\event\entity\EntityDamageEvent;

    class 
    main extends PluginBase implements Listener {
        public function 
    EntityDamage(EntityDamageEvent $event){
        if(
    $event instanceof EntityDamageByEntityEvent && $event->getEntity()->getLevel()->getName() === "WarsBow"){
          
    $entity $event->getDamager();
          if(!(
    $entity instanceof Projectile)){
             
    $event->setCancelled();
          }
        }
        }

    }
  2. BalAnce
    Offline

    BalAnce Active Member

    Joined:
    Mar 10, 2015
    Posts:
    125
    Minecraft User:
    BalAnce
    Did you register events in onEnable?
    PHP:
    public function onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this ,$this);
        }
    PEMapModder and MCPEPIG like this.
  3. DarkFlameFraYT
    Offline

    DarkFlameFraYT New Member

    Joined:
    Jul 9, 2015
    Posts:
    16
    Minecraft User:
    DarkFlameFraYT
    where do I put it?


    -Bad English and Noob :s
  4. DarkFlameFraYT
    Offline

    DarkFlameFraYT New Member

    Joined:
    Jul 9, 2015
    Posts:
    16
    Minecraft User:
    DarkFlameFraYT
    crash :(
    PHP:
    PocketMine-MP Crash Dump Fri Jul 17 13:42:05 CDT 2015

    Error
    syntax errorunexpected '$event' (T_VARIABLE)
    File: /BowPvP/src/DarkFraYT/BowPvP/main
    Line
    19
    Type
    E_PARSE

    THIS CRASH WAS CAUSED BY A PLUGIN

    Code
    :
    [
    10] use pocketmine\event\entity\EntityDamageEvent;
    [
    11] use pocketmine\event\entity\EntityDamageByEntityEvent;
    [
    12]
    [
    13] class main extends PluginBase implements Listener {
    [
    14]    
    [
    15]     public function onEnable()
    [
    16]      {$this->getServer()->getPluginManager()->registerEvents($this ,$this);
    [
    17]      {$this->getLogger()->info("§eBowPvP cargado 7w7");
    [
    18]     
    [
    19]     EntityDamage(EntityDamageEvent $event){
    [
    20]     if($event instanceof EntityDamageByEntityEvent && $event->getEntity()->getLevel()->getName() === "WarsBow"){
    [
    21]       $entity $event->getDamager();
    [
    22]       if(!($entity instanceof Projectile)){
    [
    23]          $event->setCancelled();
    [
    24]       }
    [
    25]   }
    [
    26] }
    [
    27]
    [
    28]
    [
    29
  5. BalAnce
    Offline

    BalAnce Active Member

    Joined:
    Mar 10, 2015
    Posts:
    125
    Minecraft User:
    BalAnce
    PHP:
    <?php

    namespace DarkFraYT\BowPvP;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\level\level;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\event\entity\EntityDamageEvent;

    class 
    main extends PluginBase implements Listener {
        public function 
    onEnable(){
               
    $this->getServer()->getPluginManager()->registerEvents($this ,$this);
         }

        public function 
    EntityDamage(EntityDamageEvent $event){
        if(
    $event instanceof EntityDamageByEntityEvent && $event->getEntity()->getLevel()->getName() === "WarsBow"){
          
    $entity $event->getDamager();
          if(!(
    $entity instanceof Projectile)){
             
    $event->setCancelled();
          }
        }
        }

    }
    Correct i think ^
  6. DarkFlameFraYT
    Offline

    DarkFlameFraYT New Member

    Joined:
    Jul 9, 2015
    Posts:
    16
    Minecraft User:
    DarkFlameFraYT
    ??????

    Error: Namespace declaration statement has to be the very first statement in the script
    File: /BowPvP/src/BowPvP/main
    Line: 2
    Type: E_COMPILE_ERROR

    THIS CRASH WAS CAUSED BY A PLUGIN

    Code:
    [1] <?php
    [2] namespace BowPvP;
    [3] use pocketmine\plugin\PluginBase;
    [4] use pocketmine\event\Listener;
    [5] use pocketmine\level\level;
    [6] use pocketmine\entity\Entity;
    [7] use pocketmine\event\entity\EntityDamageEvent;
  7. DarkFlameFraYT
    Offline

    DarkFlameFraYT New Member

    Joined:
    Jul 9, 2015
    Posts:
    16
    Minecraft User:
    DarkFlameFraYT
    It works now, .the events doesn't work
  8. BalAnce
    Offline

    BalAnce Active Member

    Joined:
    Mar 10, 2015
    Posts:
    125
    Minecraft User:
    BalAnce
    code?
  9. DarkFlameFraYT
    Offline

    DarkFlameFraYT New Member

    Joined:
    Jul 9, 2015
    Posts:
    16
    Minecraft User:
    DarkFlameFraYT
    It is the same
    PHP:
    <?php
    namespace WarsBow;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\listener;
    use 
    pocketmine\level\level;
    use 
    pocketmine\entity;
    use 
    pocketmine\event\entity\EntityDamageEvent;
    class 
    main extends PluginBase implements Listener {
        Public Function 
    onEnable(){
                
    $this->getServer()->getPluginManager()->registerEvents($this ,$this);
        }
       
        public function 
    EntityDamage(EntityDamageEvent $event){
        if(
    $event instanceof EntityDamageByEntityEvent && $event->getEntity()->getLevel()->getName() === "WarsBow"){
          
    $entity $event->getDamager();
          if(!(
    $entity instanceof Projectile)){
             
    $event->setCancelled();
          }
        }
       
        }
    }
  10. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Balance it will be esier if you give him working plugin and let him to read it :D
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The damager will be the creator of the projectile. You only know it when it is an EntityDamageByChildEntityEvent and the child is a projectile.
    TigerHix likes this.
  12. DarkFlameFraYT
    Offline

    DarkFlameFraYT New Member

    Joined:
    Jul 9, 2015
    Posts:
    16
    Minecraft User:
    DarkFlameFraYT
    nop,doesnt work
    PHP:
    <?php
    namespace WarsBow;
    use 
    pocketmine\event\entity\EntityDamageByEntityEvent;
    use 
    pocketmine\event\entity\EntityDamageEvent;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\level\level;
    use 
    pocketmine\plugin\PluginBase;

    class 
    main extends PluginBase implements Listener{
        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }
        public function 
    onEntityDamage(EntityDamageEvent $event){
            if(
    $event instanceof EntityDamageByChildEntityEvent && $event->getEntity()->getLevel()->getName() === "WarsBow"){
                
    $entity $event->getDamager();
        if(!(
    $entity instanceof Projectile)){
             
    $event->setCancelled();
                }
            }
        }
    }
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Read ↓
    TigerHix likes this.
  14. DarkFlameFraYT
    Offline

    DarkFlameFraYT New Member

    Joined:
    Jul 9, 2015
    Posts:
    16
    Minecraft User:
    DarkFlameFraYT

    ......
    No PvP?
    The code
    PHP:
    <?php
    namespace WarsBow;
    use 
    pocketmine\event\entity\EntityDamageByEntityEvent;
    use 
    pocketmine\event\entity\EntityDamageEvent;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\level\level;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\entity\Projectile;

    class 
    main extends PluginBase implements Listener{
        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }
        public function 
    onEntityDamage(EntityDamageEvent $event){
            if(
    $event instanceof EntityDamageByEntityEvent && $event->getEntity()->getLevel()->getName() === "WarsBow"){
                
    $entity $event->getDamager();
        if(!(
    $entity instanceof Projectile)){
             
    $event->setCancelled();
                }
            }
        }

Share This Page

Advertisement