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

Solved Teleport large number of player in the same time without lag

Comments in 'Plugin Development' started by Inta, Jul 28, 2016.

  1. Inta
    Offline

    Inta Active Member

    Joined:
    Feb 11, 2016
    Posts:
    84
    Minecraft User:
    InstantlyTa
    Just the foreach() loop. And i want to teleport 16 players in the same time without any lag. This could be delayed for some ticks.
    I need the smoothest solution please..
  2. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Wether there's lag or not is a question of how good your servers specs are or how old your players devices are. There are a few things you could to help reduce the chances of clients experiencing lag, you could have a list of predefined coords and then make sure the chunk the coords are located in is loaded by the server before you teleport players. You could also teleport all the players to their locations and not allow them to move for a short time to give clients time to render the surrounding chunks.
    Inta and SOFe like this.
  3. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    The same kind of lag to the server can happen if 16 clients join the server together.
    I don't think teleporting 1 or 16 player(s) in this case makes any difference.
    For the chunk sending, the smoothest solution is to make the player download the chunks around the target first, before teleportation.
    This can be done through Level::requestChunk(): https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/level/Level.php#L2321
    (I popped the stack 6 times to find out that function!)
    Inta likes this.
  4. Inta
    Offline

    Inta Active Member

    Joined:
    Feb 11, 2016
    Posts:
    84
    Minecraft User:
    InstantlyTa
    That's a helpful solution. Btw in my case, after teleport my code doing some heavy stuff causes lag and i thought that was the Teleport fault. But i've never heard about requesting chunks so thank you though. Maybe this topic is not an issue and never happen on anyone lol.
  5. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    Requesting chunks only means requesting a chunk to be sent, but it might not be sent immediately.

Share This Page

Advertisement