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

On respawn add effect

Discussion in 'Development' started by AlexWalker_, Aug 17, 2017.

Thread Status:
Not open for further replies.
  1. AlexWalker_

    AlexWalker_ Spider

    Messages:
    12
    GitHub:
    superalecs
    hello, in my code is how add effect to player when respawns but it doesn't work, can anyone help me?

    PHP:
        public function onRespawn(PlayerRespawnEvent $event){
            
    $player $event->getPlayer();
            
    $effect Effect::getEffect(Effect::WEAKNESS);
                
    $effect->setAmplifier(0);
                
    $effect->setDuration(10000000);
            if(
    $player->getDeviceOS() == 7){
                
    $player->addEffect($effect);
            }
        }
    Console doesn't say anything
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    You set the amplifier to 0?
     
    Last edited: Aug 18, 2017
  3. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Actually amplifier=0 is the default value. And even with effectLevel=0 the effect should still show up.
     
  4. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Possibly something about the device OS check then
     
  5. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    There is no getDeviceOS function in the player class, this is what you're looking for: https://github.com/pmmp/PocketMine-...network/mcpe/protocol/LoginPacket.php#L51-L52
     
    jasonwynn10 likes this.
  6. AlexWalker_

    AlexWalker_ Spider

    Messages:
    12
    GitHub:
    superalecs
    Sorry I doesn't spicified the effect only give for windows10 client,
    On playerjoin it works i don't know why in respawnevent doesn't work
     
  7. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    > There is no getDeviceOS function in the player class
    which is why it wont work on respawn duh
     
    HimbeersaftLP, SOFe and jasonwynn10 like this.
Thread Status:
Not open for further replies.
  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.