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

Solved Effect Not Working

Comments in 'Plugin Development' started by TryoneLegendZzz, Jul 25, 2015.

  1. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    Ok I Am Trying To Give A Player A Effecf When They Hit A Player But It Isnt Working..... Here Is My Code
    PHP:
    ublic function onHurt(EntityDamageEvent $event){
       
    $entity $event->getEntity();
    if(
    $event instanceof EntityDamageByEntityEvent){
    if(
    $event instanceof Player){
    $killer $event->getEntity()->getLastDamageCause()->getDamager();
    $cause $event->getEntity()->getName();
    if(
    $event->getDamager()->getInventory()->getItemInHand()->getId() === 272){
                    
    $event->getEntity()->addEffect(Effect::getEffect(10)->setAmplifier(1)->setDuration(6000)->setVisible(false));
        }
        }
        }
        }
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $event won't be instanceof Player.
    jojoe77777 likes this.
  3. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Use this instead of $event->getEntity()->addEffect(Effect::getEffect(10)->setAmplifier(1)->setDuration(6000)->setVisible(false)); (This wouldn't work anyways...) EDIT: It works

    $effect = Effect::getEffect(10);
    $effect->setAmplifier(1);
    $effect->setDuration(6000);
    $effect->setVisible(false);
    $entity->addEffect($effect);
    Last edited: Jul 25, 2015
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It has no difference with $entity->addEffect(Effect::getEffect(10)->setAmplifier(1)->setDuration(6000)->setVisible(false));
  5. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Oh...
  6. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    so wat do i do...
  7. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    Nvm Fixed It

Share This Page

Advertisement