summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins/Core/teleport.lua
diff options
context:
space:
mode:
authorAlexander Harkness <bearbin@gmail.com>2013-08-11 17:00:53 +0200
committerAlexander Harkness <bearbin@gmail.com>2013-08-11 17:00:53 +0200
commitcc708f757c19a2e0c66f138897f41d86d46dd0fb (patch)
tree768cee0a544f131cf6964c058ec2881346880804 /MCServer/Plugins/Core/teleport.lua
parentAdded the OnHopperPullingItem and OnHopperPushingItem hooks. (diff)
downloadcuberite-cc708f757c19a2e0c66f138897f41d86d46dd0fb.tar
cuberite-cc708f757c19a2e0c66f138897f41d86d46dd0fb.tar.gz
cuberite-cc708f757c19a2e0c66f138897f41d86d46dd0fb.tar.bz2
cuberite-cc708f757c19a2e0c66f138897f41d86d46dd0fb.tar.lz
cuberite-cc708f757c19a2e0c66f138897f41d86d46dd0fb.tar.xz
cuberite-cc708f757c19a2e0c66f138897f41d86d46dd0fb.tar.zst
cuberite-cc708f757c19a2e0c66f138897f41d86d46dd0fb.zip
Diffstat (limited to 'MCServer/Plugins/Core/teleport.lua')
-rw-r--r--MCServer/Plugins/Core/teleport.lua74
1 files changed, 47 insertions, 27 deletions
diff --git a/MCServer/Plugins/Core/teleport.lua b/MCServer/Plugins/Core/teleport.lua
index 1e2cab6f7..70aee131c 100644
--- a/MCServer/Plugins/Core/teleport.lua
+++ b/MCServer/Plugins/Core/teleport.lua
@@ -1,80 +1,100 @@
function HandleTPCommand(a_Split, a_Player)
- if ((#a_Split == 2) or (#a_Split == 3)) then
+
+ if #a_Split == 2 or #a_Split == 3 then
+
-- Teleport to player specified in a_Split[2], tell them unless a_Split[3] equals "-h":
- TeleportToPlayer(a_Player, a_Split[2], (a_Split[3] ~= "-h"));
- return true;
- elseif (#a_Split == 4) then
+ TeleportToPlayer( a_Player, a_Split[2], (a_Split[3] ~= "-h") )
+ return true
+
+ elseif #a_Split == 4 then
+
-- Teleport to XYZ coords specified in a_Split[2, 3, 4]:
- SetBackCoordinates(a_Player);
- a_Player:TeleportToCoords(a_Split[2], a_Split[3], a_Split[4]);
- a_Player:SendMessage(cChatColor.Green .. "[INFO] " .. cChatColor.White .. "You teleported to [X:" .. a_Split[2] .. " Y:" .. a_Split[3] .. " Z:" .. a_Split[4] .. "]");
- return true;
+ SetBackCoordinates(a_Player)
+ a_Player:TeleportToCoords( a_Split[2], a_Split[3], a_Split[4] )
+ SendMessageSuccess( a_Player, "You teleported to [X:" .. a_Split[2] .. " Y:" .. a_Split[3] .. " Z:" .. a_Split[4] .. "]" )
+ return true
+
else
- a_Player:SendMessage(cChatColor.Yellow .. "[INFO] " .. cChatColor.White .. "Usage: /tp [PlayerName] (-h) or /tp [X Y Z]" )
+ SendMessage( a_Player, "Usage: /tp [PlayerName] (-h) or /tp [X Y Z]" )
return true
end
+
end
function HandleTPACommand( Split, Player )
+
if Split[2] == nil then
- Player:SendMessage(cChatColor.Yellow .. "[INFO] " .. cChatColor.White .. "Usage: /tpa [Player]" )
+ SendMessage( Player, "Usage: /tpa [Player]" )
return true
end
+
local loopPlayer = function( OtherPlayer )
if OtherPlayer:GetName() == Split[2] then
- OtherPlayer:SendMessage(cChatColor.Yellow .. "[INFO] " .. cChatColor.White .. Player:GetName() .. " send a teleport request" )
- Player:SendMessage(cChatColor.Green .. "[INFO] " .. cChatColor.White .. "You send a teleport request to " .. OtherPlayer:GetName() )
+ SendMessage( OtherPlayer, Player:GetName() .. " send a teleport request" )
+ SendMessageSuccess( Player, "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.Rose .. "[INFO] " .. cChatColor.White .. "Nobody has send you a teleport request" )
+ SendMessageFailure( Player, "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.Yellow .. "[INFO] " .. cChatColor.White .. OtherPlayer:GetName() .. " teleported to you" )
- OtherPlayer:SendMessage(cChatColor.Green .. "[INFO] " .. cChatColor.White .. "You teleported to " .. Player:GetName() )
+ SendMessage( Player, OtherPlayer:GetName() .. " teleported to you" )
+ SendMessageSuccess( OtherPlayer, "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)
+function TeleportToPlayer( a_SrcPlayer, a_DstPlayerName, a_TellDst )
+
local teleport = function(OtherPlayer)
- if (OtherPlayer == a_SrcPlayer) then
+
+ if OtherPlayer == a_SrcPlayer then
-- Asked to teleport to self?
- a_SrcPlayer:SendMessage(cChatColor.Rose .. "[INFO] " .. cChatColor.White .. "Y' can't teleport to yerself!");
+ SendMessageFailure( a_SrcPlayer, "Y' can't teleport to yerself!" )
else
- SetBackCoordinates(a_SrcPlayer);
- a_SrcPlayer:TeleportToEntity(OtherPlayer);
- a_SrcPlayer:SendMessage(cChatColor.Green .. "[INFO] " .. cChatColor.White .. "You teleported to " .. OtherPlayer:GetName() .. "!");
+ SetBackCoordinates( a_SrcPlayer )
+ a_SrcPlayer:TeleportToEntity( OtherPlayer )
+ SendMessageSuccess( a_SrcPlayer, "You teleported to " .. OtherPlayer:GetName() .. "!" )
if (a_TellDst) then
- OtherPlayer:SendMessage(cChatColor.Yellow .. "[INFO] " .. cChatColor.White .. Player:GetName().." teleported to you!");
+ SendMessage( OtherPlayer, Player:GetName().." teleported to you!" )
end
end
+
end
-
- local World = a_SrcPlayer:GetWorld();
- if (not(World:DoWithPlayer(a_DstPlayerName, teleport))) then
- a_SrcPlayer:SendMessage(cChatColor.Rose .. "[INFO] " .. cChatColor.White .. "Can't find player " .. a_DstPlayerName);
+
+ local World = a_SrcPlayer:GetWorld()
+ if not World:DoWithPlayer(a_DstPlayerName, teleport) then
+ SendMessageFailure( a_SrcPlayer, "Can't find player " .. a_DstPlayerName)
end
-end \ No newline at end of file
+
+end