diff options
author | Alexander Harkness <bearbin@gmail.com> | 2013-07-27 17:54:25 +0200 |
---|---|---|
committer | Alexander Harkness <bearbin@gmail.com> | 2013-07-27 17:54:25 +0200 |
commit | 7d28f8bbff2dedcf63466618372ecf3d8d05bbc3 (patch) | |
tree | 8e361cc8dac17fbe13a48a027111e9e187930fe0 /MCServer/Plugins/Core/teleport.lua | |
parent | Added correct core plugin (diff) | |
download | cuberite-7d28f8bbff2dedcf63466618372ecf3d8d05bbc3.tar cuberite-7d28f8bbff2dedcf63466618372ecf3d8d05bbc3.tar.gz cuberite-7d28f8bbff2dedcf63466618372ecf3d8d05bbc3.tar.bz2 cuberite-7d28f8bbff2dedcf63466618372ecf3d8d05bbc3.tar.lz cuberite-7d28f8bbff2dedcf63466618372ecf3d8d05bbc3.tar.xz cuberite-7d28f8bbff2dedcf63466618372ecf3d8d05bbc3.tar.zst cuberite-7d28f8bbff2dedcf63466618372ecf3d8d05bbc3.zip |
Diffstat (limited to 'MCServer/Plugins/Core/teleport.lua')
-rw-r--r-- | MCServer/Plugins/Core/teleport.lua | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/MCServer/Plugins/Core/teleport.lua b/MCServer/Plugins/Core/teleport.lua index 4d3d98fee..89352408a 100644 --- a/MCServer/Plugins/Core/teleport.lua +++ b/MCServer/Plugins/Core/teleport.lua @@ -15,6 +15,48 @@ function HandleTPCommand(a_Split, a_Player) end end +function HandleTPACommand( Split, Player ) + if Split[2] == nil then + Player:SendMessage( cChatColor.Green .. "Usage: /tpa [Player]" ) + return true + end + local loopPlayer = function( OtherPlayer ) + if OtherPlayer:GetName() == Split[2] then + OtherPlayer:SendMessage( cChatColor.Green .. Player:GetName() .. " send a teleport request" ) + Player:SendMessage( cChatColor.Green .. "You send a teleport request to " .. OtherPlayer:GetName() ) + Destination[OtherPlayer:GetName()] = Player:GetName() + end + end + local loopWorlds = function( World ) + World:ForEachPlayer( loopPlayer ) + end + cRoot:Get():ForEachWorld( loopWorlds ) + return true +end + +function HandleTPAcceptCommand( Split, Player ) + if Destination[Player:GetName()] == nil then + Player:SendMessage( cChatColor.Green .. "Nobody has send you a teleport request" ) + return true + end + local loopPlayer = function( OtherPlayer ) + if Destination[Player:GetName()] == OtherPlayer:GetName() then + if OtherPlayer:GetWorld():GetName() ~= Player:GetWorld():GetName() then + OtherPlayer:MoveToWorld( Player:GetWorld():GetName() ) + end + OtherPlayer:TeleportToEntity( Player ) + Player:SendMessage( cChatColor.Green .. OtherPlayer:GetName() .. " teleported to you" ) + OtherPlayer:SendMessage( cChatColor.Green .. "You teleported to " .. Player:GetName() ) + Destination[Player:GetName()] = nil + end + end + local loopWorlds = function( World ) + World:ForEachPlayer( loopPlayer ) + end + cRoot:Get():ForEachWorld( loopWorlds ) + return true +end + -- Teleports a_SrcPlayer to a player named a_DstPlayerName; if a_TellDst is true, will send a notice to the destination player function TeleportToPlayer(a_SrcPlayer, a_DstPlayerName, a_TellDst) local teleport = function(OtherPlayer) |