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

Plugin

Discussion in 'Development' started by QuiverlyRivalry, Oct 11, 2017.

  1. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
    Hi,
    I tried to make a plugin which will spawn you in default world (hub world) once you die. But when I die it spawns me in the same world. Any help?
    Code:
    <?php
    namespace DIErespawnCR;
    use pocketmine\plugin\PluginBase;
    use pocketmine\event\Listener;
    use pocketmine\event\player\PlayerRespawnEvent;
    use pocketmine\math\Vector3;
    class Main extends PluginBase implements Listener{
     
        public function onEnable(){
            $this->getServer()->getPluginManager()->registerEvents($this, $this);
            $this->getServer()->getLogger()->info("DIErespawnCR Enabled!");
        }
     
        public function onDisable(){
            $this->getServer()->getLogger()->info("DIErespawnCR Disabled!");
        }
     
        public function onRespawn(PlayerRespawnEvent $event){
            $player = $event->getPlayer();
            $player->teleport($player->getLevel()->getSafeSpawn());
        }
    }
    
     
  2. r7vmc

    r7vmc Baby Zombie

    Messages:
    112
    GitHub:
    r7vmc
    you must be meaning this

    PHP:
    <?php
    namespace DIErespawnCR;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerRespawnEvent;
    use 
    pocketmine\math\Vector3;
    class 
    Main extends PluginBase implements Listener{

        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getServer()->getLogger()->info("DIErespawnCR Enabled!");
        }

        public function 
    onDisable(){
            
    $this->getServer()->getLogger()->info("DIErespawnCR Disabled!");
        }

        public function 
    onRespawn(PlayerRespawnEvent $event){
            
    $player $event->getPlayer();
            
    $player->teleport($this->getServer()->getDefaultLevel()->getSpawn());
        }
    }
     
  3. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
    yes but id there a way to fix my plugin?
     
  4. r7vmc

    r7vmc Baby Zombie

    Messages:
    112
    GitHub:
    r7vmc
    did you even look ?
    PHP:
             $player->teleport($this->getServer()->getDefaultLevel()->getSpawn()); 
     
    Levi likes this.
  5. HBIDamian

    HBIDamian HBIDamian Staff Member

    Messages:
    365
    GitHub:
    HBIDamian
    PHP:

    <?php
    namespace DIErespawnCR;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerRespawnEvent;
    use 
    pocketmine\math\Vector3;
    class 
    Main extends PluginBase implements Listener{

        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getServer()->getLogger()->info("DIErespawnCR Enabled!");
        }

        public function 
    onDisable(){
            
    $this->getServer()->getLogger()->info("DIErespawnCR Disabled!");
        }

        public function 
    onRespawn(PlayerRespawnEvent $event){
            
    $player $event->getPlayer();
            
    $player->teleport($this->getServer()->getDefaultLevel()->getSafeSpawn());
        }
    }
     
  6. HBIDamian

    HBIDamian HBIDamian Staff Member

    Messages:
    365
    GitHub:
    HBIDamian
    Also... Please stop making stupidly plain titles such as "Plugin"... you need to be more detailed...
    For example: "Plugin Teleport Spawn Error".

    And, one last thing...
    Instead of the [ code] tags... use php tags instead. ;)
     
  7. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
    ohh thanks deibo and will do
     
  8. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
    oh sorry the time i replied to that, i was on my phone
     
  9. r7vmc

    r7vmc Baby Zombie

    Messages:
    112
    GitHub:
    r7vmc
    Ok np
     
  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.