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

Check if player hits some mob

Comments in 'Plugin Development' started by Flabe, Mar 2, 2016.

  1. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    Hello friends i tried to use this code to check if player hits some mob, but when i hit mob nothing happens.
    What's wrong with my code???
    PHP:
    public function onDamage(EntityDamageEvent $ev){
    if(
    $ev instanceof EntityDamageByEntityEvent) {
    $entt $ev->getEntity();
    $damger $ev->getDamager();
    if(
    $entt instanceof Creeper) {
    $ev->setCancelled();
    $damager->sendMessage("§l§eCREEPER");
    }
    }
    }
    ---------------------------
    Answer please if you know, i'll be very happy! ^-^
    Last edited: Mar 2, 2016
  2. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    And I know about slapper plugin, but that code didn't help me(
  3. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    what is los
    PHP:
    $los->setCancelled();
    // FIX
    $ev->setCancelled();
  4. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    PHP:
    public function onDamage(EntityDamageEvent $ev){
    if(
    $ev instanceof EntityDamageByEntityEvent) {
    $entt $ev->getEntity();
    $damger $ev->getDamager();
    if(
    $entt instanceof Creeper) {
    $ev->setCancelled();
    $damager->sendMessage("§l§eCREEPER");
    }
    }
    }
  5. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    but it don't work too...
  6. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    Thx for your reply))
  7. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    oh it still not working:(
  8. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    WTF it can... Don't mislead others. First, did you register events??
  9. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    yeah
    PHP:
    public function onEnable(){
            
    $this->getLogger()->info("Плагин запуск........");
            
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
        }
  10. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    but it don't works...
  11. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    idk what's the problem(((
  12. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Ah are you using the newest PM build?
  13. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    i use genysis core(modified pocketmine)
  14. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    thanks every1 i solved it , the problem was in import lol :D
  15. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    PHP:
    $damger $ev->getDamager();
    $damager->sendMessage("§l§eCREEPER");
    If this was copied and pasted here, be careful on spellings.

Share This Page

Advertisement