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

AddEffect to PlayerRespawnEvent

Discussion in 'Facepalm' started by AlexWalker_, Aug 19, 2017.

  1. AlexWalker_

    AlexWalker_ Spider

    Messages:
    12
    GitHub:
    superalecs
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Rather than linking visitors to check another thread before answering this one, rephrase what you said in that post in better words.
     
    jasonwynn10 likes this.
  3. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    of course it would be broken if you removed it
    like can a car run with their tires removed? no
    you should try something else...
    and we couldnt help you without code
     
    jasonwynn10 likes this.
  4. AlexWalker_

    AlexWalker_ Spider

    Messages:
    12
    GitHub:
    superalecs
    PHP:
        public function onRespawn(PlayerRespawnEvent $event){
            
    $player $event->getPlayer();
            
    $effect Effect::getEffect(Effect::WEAKNESS);
                
    $effect->setAmplifier(0);
                
    $effect->setDuration(10000000);
                
    $player->addEffect($effect);
            
        }
     
  5. moska

    moska Baby Zombie

    Messages:
    105
    GitHub:
    supermaxalex
    Have you registered the event ?
     
    jasonwynn10 and Sandertv like this.
  6. AlexWalker_

    AlexWalker_ Spider

    Messages:
    12
    GitHub:
    superalecs
    Of course, it won't work only with PlayerRespawnEvent, I added addEffect on PlayerJoinEvent and it works...
     
  7. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    I've heard of this issue before. PlayerRespawnEvent gets called pre-respawn, as that's how the event API works. All effects of the player respawning get cleared later in the respawn sequence, so you'll have to end up using a task.
     
  8. AlexWalker_

    AlexWalker_ Spider

    Messages:
    12
    GitHub:
    superalecs
    Can you write the code how to do? Because I really don't know how...
     
  9. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Did you understand what he wrote?
     
  10. xXSirButterXx

    xXSirButterXx Witch

    Messages:
    52
    GitHub:
    xxsirbutterxx
     
  11. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    that will be a hella fun time breaking in an instance of accident
     
    jasonwynn10 likes this.
  12. AlexWalker_

    AlexWalker_ Spider

    Messages:
    12
    GitHub:
    superalecs
    Please don't make this thread off topic
     
    xXSirButterXx and jasonwynn10 like this.
  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.