1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Remove All Effect From Player

Discussion in 'Development' started by Bintang Putra, Jun 9, 2017.

  1. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Hi, i use effect using
    PHP:
    $ev->getPlayer()->addEffect(Effect::SPEED);
    $ev->getPlayer()->addEffect(Effect::WEAKNESS);
    Now, How to remove all effect from the player
    using removeEffect() ?
     
  2. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
  3. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    oh, using foreach?
    im sorry, im a newbie at php so i dont know which function to use :(
     
  4. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Why I Get integer ?
     

    Attached Files:

  5. Keith

    Keith Spider Jockey

    Messages:
    42
    GitHub:
    k3ithos
    You can use $player->removeAllEffects() to remove all effects from a player. As for removing a specific effect, I would think that the appropriate function would be $player->removeEffect(), so if you wanted to remove speed effect from a player:
    PHP:
    $player->removeEffect(Effect::SPEED);
     
  6. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Yes, Thank You :D
     
  7. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    btw, How to specify how much effect given, example i want to give SPEED 12
     
  8. Keith

    Keith Spider Jockey

    Messages:
    42
    GitHub:
    k3ithos
    In that case, this might be the better solution:
    PHP:
    $effect Effect::getEffect(Effect::SPEED)->setDuration(60)->setAmplifier(12);
    $player->addEffect($effect);
    Do keep in mind that 60 seconds in the duration field is only an example...
    --
    Cleaner:
    PHP:
    $player->addEffect(Effect::getEffect(Effect::SPEED)->setDuration(60)->setAmplifier(12));
     
    kazuya likes this.
  9. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Thanks Man :D
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.