Cuberite Forum
Void Teleport to spawn - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: Void Teleport to spawn (/thread-2513.html)



Void Teleport to spawn - feardevilz - 09-12-2016

Hi all,
I'm trying to add in Void to spawn teleporting, if someone were to jump off the edge of the lobby world. I took a look at Highjump and the API calls. I got the function listed but its not doing the teleport. Can anyone tell me if I am missing something? Possibly a call to look up default world?

Code:
function OnPlayerMoving(Player)
       local World = Player:GetWorld()
       if(Player:IsOnGround() == false) and (Player:IsGameModeCreative() == false) and (Player:CanFly() == false) and (Player:GetPosY() <= 0) then
               Player:TeleportToCoords(World:GetSpawnX(), World:GetSpawnY(), World:GetSpawnZ())
       end
end

Using this does prevent death but it glitches the client and doesn't teleport.
Thanks in advanced!


RE: Void Teleport to spawn - NiLSPACE - 09-12-2016

A simple
function OnPlayerMoving(Player)
    if (Player:GetPosY() < 0) then
        local World = Player:GetWorld()
        Player:TeleportToCoords(World:GetSpawnX(), World:GetSpawnY(), World:GetSpawnZ())
    end
end
Also, don't forget to add the hook on initialization of the plugin:
cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_MOVING, OnPlayerMoving);



RE: Void Teleport to spawn - feardevilz - 09-12-2016

(09-12-2016, 03:40 AM)NiLSPACE Wrote: A simple
function OnPlayerMoving(Player)
    if (Player:GetPosY() < 0) then
        local World = Player:GetWorld()
        Player:TeleportToCoords(World:GetSpawnX(), World:GetSpawnY(), World:GetSpawnZ())
    end
end
Also, don't forget to add the hook on initialization of the plugin:
cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_MOVING, OnPlayerMoving);

Thanks! I did have the hook in, just forgot to mention that. I tested your change and it does seem to teleport the player but it seems glitched on my client. I also tried in native MC 1.10.2 and still seeing the glitch. It looks almost like a video refresh issue. It flickers like crazy.