Void Teleport to spawn
#1
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!
Reply
Thanks given by:
#2
A simple
1
2
3
4
5
6
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:
1
cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_MOVING, OnPlayerMoving);
Reply
Thanks given by:
#3
(09-12-2016, 03:40 AM)NiLSPACE Wrote: A simple
1
2
3
4
5
6
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:
1
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.
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)