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

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:
    187
    GitHub:
    mr174
    Everytime they join?
     
  3. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    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 Baby Zombie

    Messages:
    134
    GitHub:
    provsalt
    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 Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    Please at least feed something that works
    Did you even test that?
     
  6. Provsnoobgaming

    Provsnoobgaming Baby Zombie

    Messages:
    134
    GitHub:
    provsalt
    i forgoten the ; on the PluginBase and Eventlistener
    Also you need the eventlistener fild
     
  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.