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

Solved Problem with a part in my Core

Discussion in 'Development' started by Akuroma, Jun 3, 2017.

  1. Akuroma

    Akuroma Silverfish

    Messages:
    20
    GitHub:
    Akuroma
    Hey. I'd like that players spawn in my Lobby, everytime they join onto the server. My code which you can see below, worked perfectly with Tesseract. Since I use PocketMine-MP, it doesn't work anymore. No error outputs, no crashdumps, it just won't work. The class is defined by using "use pocketmine\event\player\PlayerJoinEvent;".

    If you are reporting a regression or unexpected behaviour, please include the below information:
    Expected result: Players should spawn at the servers spawn point on join.
    Actual result: Nothing happens. Players spawn on there last point, before quit.

    • PocketMine-MP: PocketMine-MP 1.6.2dev 「Unleashed」
    • PHP: 7.0
    • Server OS: Linux (Ubuntu 14.04)
    • Game version: PE/Win10
    [​IMG]
     
  2. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Could you please show more of your code. From what we can see, everything would work fine. We don't know however, if you for example forgot to register events, or something similar. Did you forget to implement Listener maybe? Does the plugin even get enabled at all?
     
  3. Akuroma

    Akuroma Silverfish

    Messages:
    20
    GitHub:
    Akuroma
    upload_2017-6-3_16-49-29.png

    upload_2017-6-3_16-50-7.png

    upload_2017-6-3_16-50-41.png

    These are some parts of the code. The plugin actually is enabled and also the commands like /hub and so on work fine. Only the teleport on join doesn't work :/
     
  4. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    On line 56 use:
    PHP:
     if ($event->getCause() === EntityDamageEvent::CAUSE_FALL)  $ev-> setCancelled() 
     
    Last edited: Jun 3, 2017
  5. Intyre

    Intyre Administrator Staff Member PMMP Team

    Messages:
    81
    GitHub:
    Intyre
    jasonwynn10, SOFe and Sandertv like this.
  6. Akuroma

    Akuroma Silverfish

    Messages:
    20
    GitHub:
    Akuroma
    So apparently it has to be
    PHP:
    $this->teleport(...);
    ? Or am I wrong? xD
     
  7. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    According to @Intyre's hints, the following happens when a player joins:
    1. PlayerJoinEvent is called
    2. PlayerRespawnEvent is called.
    3. The server teleports the player to the spawn location set in PlayerRespawnEvent.

    Therefore, you should use PlayerRespawnEvent instead of PlayerJoinEvent to teleport the player.
     
  8. Akuroma

    Akuroma Silverfish

    Messages:
    20
    GitHub:
    Akuroma
    So the Code would be:
    PHP:
    public function onRespawn(PlayerRespawnEvent $respawn){
            
    $player $respawn->getPlayer();
            
    $player->teleport($this->getServer()->getDefaultLevel()->getSpawnLocation());
        }
    ?
    Is this right? Because I want that the player is getting teleported, when he joins the server. Not when he dies or something else. And it also doesn't work.
     
  9. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    No. Set the respawn location in the PlayerRespawnEvent.
    https://github.com/pmmp/PocketMine-...e/event/player/PlayerRespawnEvent.php#L55-L57
     
    0x15f and Muqsit like this.
  10. Akuroma

    Akuroma Silverfish

    Messages:
    20
    GitHub:
    Akuroma
    upload_2017-6-4_13-23-10.png

    Like this?
     
  11. jarne

    jarne Spider

    Messages:
    7
    GitHub:
    jarne
    No, you don't need to define this function yourself, you need to call it.

    Like this:
    PHP:
    public function onRespawn(PlayerRespawnEvent $respawn){
            
    $player $respawn->getPlayer();
            
    $respawn->setRespawnPosition($this->getServer()->getDefaultLevel()->getSpawnLocation());
    }
     
    SOFe and Sandertv like this.
  12. Akuroma

    Akuroma Silverfish

    Messages:
    20
    GitHub:
    Akuroma
    Now I've tried many things. But none of them is working :/ I don't think that this is a problem with my plugins or something like that. I think this issue is related to PMMP. thebigsmilexd apparently also had this issue.
     
  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.