How to delay teleporting? Like 6-7 seconds from a task, so lag gets reduced .. and if the player moves while teleporting scheduler is running, it should get cancelled, i think that could be done by sending the player's position to the scheduler and checking if they are the same after 6-7 seconds?
Task isn't needed. Use time(), if you understand it. If you don't, here; https://github.com/SOF3/forums-common-sense/wiki/PocketMine-Plugin-Development-FAQ Read 'Cancelling Event a few seconds later'.
are you trying to do a TP warnup? please give us more context as for how that would reduce "lag" if you are doing a warmup TP task is the way to go the Task will be a delayed task, accepting Player, which you pass cloned Player in(citation needed: reasoning since the player will move and we just want the current pos not future pos) in the onRun, you should distance cloned Player with CURRENT player by getting the player using server with the name off cloned player not tested, but should work, if not pass in a just reconstruct the vector3 and player name, using these instated
I do this in SimpleWarp, not sure if it reduces lag though. See https://github.com/Falkirks/SimpleWarp/blob/master/src/falkirks/simplewarp/task/PlayerWarpTask.php and https://github.com/Falkirks/SimpleW...ks/simplewarp/command/WarpCommand.php#L50-L51. The second link uses CommandWarpTask which is just a subtype of PlayerWarpTask which send messages to the CommandSender about the status of the warp.
I think you should do this too.. PHP: /** @var Position $warp *///class extending Taskpublic function __construct(...){ //... $warp->getLevel()->loadChunk($warp->x >> 4, $warp->z >> 4);}
Nope, my code is happy the way it is. If I was using teleportImmediate I would need to do this. But teleport handles the chunk loading and waits until chunks are sent.