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

How to spawn lightining on playerdeathevent.

Discussion in 'Development' started by Remarkabless, Nov 21, 2017.

  1. Remarkabless

    Remarkabless Slime

    Messages:
    83
    GitHub:
    Remakem
    PHP:

    public function onDeath(PlayerDeathEvent $event) {
        
    $player $event->getPlayer();
        
    //SPAWN LIGHTNING?
    }
    i know its sounds involved but I simply dont know how any help thanks!
     
  2. Remarkabless

    Remarkabless Slime

    Messages:
    83
    GitHub:
    Remakem
  3. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
  4. Remarkabless

    Remarkabless Slime

    Messages:
    83
    GitHub:
    Remakem
  5. Daniel23

    Daniel23 Witch

    Messages:
    65
    GitHub:
    daniel23
  6. SleepSpace9

    SleepSpace9 Slime

    Messages:
    78
    GitHub:
    sleepspace9
    I'm using this, it also contains a parameter for the height:

    PHP:
    public function addStrike(Player $p$height){
        
    $level $p->getLevel();
        
    $light = new AddEntityPacket();
        
    $light->type 93;
        
    $light->entityRuntimeId Entity::$entityCount++;
        
    $light->metadata = array();
        
    $light->position $p->asVector3()->add(0,$height,0);
        
    $light->yaw $p->getYaw();
        
    $light->pitch $p->getPitch();
        
    $p->getServer()->broadcastPacket($level->getPlayers(),$light);
    }
    public function 
    onDeath(PlayerDeathEvent $e){
        
    $p $e->getEntity();
        if(
    $p instanceof Player){
            
    $this->addStrike($p,<here comes your height value>);
        }
    }

     
    Last edited: Nov 22, 2017
    OnTheVerge likes this.
  7. Remarkabless

    Remarkabless Slime

    Messages:
    83
    GitHub:
    Remakem
    Yes but after I do this how do i call the function into the playerdeathevent? Like how do I make this function happen on PlayerDeathEvent is what I dont know
     
  8. SleepSpace9

    SleepSpace9 Slime

    Messages:
    78
    GitHub:
    sleepspace9
    I've just updated the snippet after reading your original question.
     
  9. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    But what's the height for? Why not strike it exactly where the player is? :rolleyes:
     
  10. SleepSpace9

    SleepSpace9 Slime

    Messages:
    78
    GitHub:
    sleepspace9
    It's optional and depends on your personal purpose. If you like it exactly at the player then use 0 for the height value. If you like it above the player in the air then use a higher value. ¯\_(ツ)_/¯
     
  11. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Because the API that the post used is outdated
     
    Daniel23 likes this.
  12. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    Use the EssentialsPE spawn lighting function, just call it from your plugin.
     
  13. TGames

    TGames Silverfish

    Messages:
    18
  14. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    that's not really ideal to embed a bulky plugin for that uses
     
  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.