Add a Effect onJoin

Discussion in 'Development' started by Lander09yt, Jul 14, 2019.

  1. Lander09yt

    Lander09yt Creeper

    Messages:
    4
    GitHub:
    Lander09yt
    Hey, i want to make a plugin, that gives the player resistance 200 for 10 Seconds, when he join the Server.
    How do i code it?
     
  2. Mr174

    Mr174 Baby Zombie

    Messages:
    110
    GitHub:
    Mr174
    Everytime they join?
     
  3. Mr174

    Mr174 Baby Zombie

    Messages:
    110
    GitHub:
    Mr174
    use pocketmine\entity\Effect;
    use pocketmine\entity\EffectInstance;

    PHP:
    public function join(PlayerJoinEvent $ev) {
            
    $p $ev->getPlayer();
            
    $p->addEffect(new EffectInstance(Effect::getEffect(Effect::RESISTANCE),200,1,false));
        }
     
    wolfdale likes this.
  4. Provsnoobgaming

    Provsnoobgaming Silverfish

    Messages:
    24
    GitHub:
    provsnoobgaming
    I like spoon feeding so here you go
    PHP:
    <?php

    namespace PluginName

    use pocketmine\PluginBase:
    use 
    pocketmine\event\Eventlistener;
    use 
    pocketmine\entity\Effect;
    use 
    pocketmine\entity\EffectInstance;

    class 
    Main extends PluginBase implements listener {
        public function 
    onEnable {
         
        
    $this->getServer()->getPluginManager()->registerEvents(new \directoryto\EventListener($this), $this);
        }
        public function 
    join(PlayerJoinEvent $ev) {
            
    $p $ev->getPlayer();
            
    $p->addEffect(new EffectInstance(Effect::getEffect(Effect::RESISTANCE),200,1,false));
        }
      }
    }
     
    Last edited: Jul 15, 2019
    Mr174 likes this.
  5. wolfdale

    wolfdale Zombie

    Messages:
    367
    Please at least feed something that works
    Did you even test that?
     
  6. Provsnoobgaming

    Provsnoobgaming Silverfish

    Messages:
    24
    GitHub:
    provsnoobgaming
    i forgoten the ; on the PluginBase and Eventlistener
    Also you need the eventlistener fild
     

Share This Page

  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.