Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Respawn on Death

Comments in 'Plugin Development' started by KHAV, Sep 14, 2016.

  1. KHAV
    Offline

    KHAV New Member

    Joined:
    Aug 7, 2016
    Posts:
    35
    Minecraft User:
    KHAV
    Hi

    How I Can Make When Player Death Respawn Automatic You Shouldn't Click On Respawn

    Sorry for my bad english xD
  2. archie426
    Offline

    archie426 Active Member

    Joined:
    Apr 26, 2015
    Posts:
    193
    Minecraft User:
    archie426
    You mean like instead of showing the respawn screen it will automatically teleport to the spawn point for that player?
  3. KHAV
    Offline

    KHAV New Member

    Joined:
    Aug 7, 2016
    Posts:
    35
    Minecraft User:
    KHAV
    Yes!!:)
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    You can simply use
    PHP:
    if($event->getDamage() >= $event->getEntity()->getHealth()){
    $event->setCancelled();
    // heal player
    // tp player
    }
    while $event is EntityDamageEvent and $event->getEntity() is instanceof Player.
    Muqsit likes this.
  5. KHAV
    Offline

    KHAV New Member

    Joined:
    Aug 7, 2016
    Posts:
    35
    Minecraft User:
    KHAV

    Notice: Trying to get property of non-object in /storage/emulated/0/PocketMine/plugins/FastRespawn/src/FastRespawn/Main.php on line 23
    [02:43:47] [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\entity\EntityDamageByEntityEvent' to 'FastRespawn v1.0.0': Call to a member function getEntity() on null on FastRespawn\Main
    [02:43:47] [Server thread/CRITICAL]: Error: "Call to a member function getEntity() on null" (EXCEPTION) in "/FastRespawn/src/FastRespawn/Main" at line 23

    When i get Damage Type For me This in console
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    public function onDamage(EntityDamageEvent $event)
    Go learn PHP
    Last edited: Sep 14, 2016
    archie426 likes this.
  7. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
  8. KHAV
    Offline

    KHAV New Member

    Joined:
    Aug 7, 2016
    Posts:
    35
    Minecraft User:
    KHAV
    Thank you CraftYourBukkit The Code Is Working But i Have Some Proplems
    Same i want when player killed by player sendmessage $player was slain by $killer and i am added Clearall on death but i want to make config if you want to clearinventory on death or no and thanks:)
  9. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    PHP:
    if($entity instanceof Player && $damager instanceof Player){
    $playername $entity->getName();
    $killername $damager->getName();
    }
  10. Ragnok1234
    Offline

    Ragnok1234 Active Member

    Joined:
    Jul 18, 2016
    Posts:
    53
    Minecraft User:
    Ragnok123
    I have this:
    PHP:
    if($entity->getHealth() == 0){
    $entity->teleport(new Vector3($x$y$z));
    }
    Ps.: $entity is $event->getEntity(); and $x/$y/$z is $this->getServer()->getDefaultLevel()->getSafeSpawn()->getX()/Y()/Z();
  11. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    You can pass Level::getSafeSpawn() into Entity::teleport() instead of constructing new Vector3 instance.

Share This Page

Advertisement