summaryrefslogtreecommitdiffstats
path: root/MCServer
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-07-07 21:57:56 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-07-07 21:57:56 +0200
commit0756c72486444f24664fe0605bbc135725c77f9a (patch)
treebcfd587d95514d0a2b3fb27df3d693dbc35292cc /MCServer
parentMobs are assigned MaxHealth from monsters.ini; reading monsters.ini doesn't need settings.ini values anymore. (diff)
downloadcuberite-0756c72486444f24664fe0605bbc135725c77f9a.tar
cuberite-0756c72486444f24664fe0605bbc135725c77f9a.tar.gz
cuberite-0756c72486444f24664fe0605bbc135725c77f9a.tar.bz2
cuberite-0756c72486444f24664fe0605bbc135725c77f9a.tar.lz
cuberite-0756c72486444f24664fe0605bbc135725c77f9a.tar.xz
cuberite-0756c72486444f24664fe0605bbc135725c77f9a.tar.zst
cuberite-0756c72486444f24664fe0605bbc135725c77f9a.zip
Diffstat (limited to '')
-rw-r--r--MCServer/Plugins/Core/teleport.lua52
1 files changed, 37 insertions, 15 deletions
diff --git a/MCServer/Plugins/Core/teleport.lua b/MCServer/Plugins/Core/teleport.lua
index 5a004591b..ad9e7be69 100644
--- a/MCServer/Plugins/Core/teleport.lua
+++ b/MCServer/Plugins/Core/teleport.lua
@@ -1,24 +1,46 @@
-function HandleTPCommand( Split, Player )
- if( Split[2] == nil ) then
+function HandleTPCommand(a_Split, a_Player)
+ 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
+ -- 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 .. "You teleported to {" .. a_Split[2] .. ", " .. a_Split[3] .. ", " .. a_Split[4] .. "}");
+ return true;
+ else
Player:SendMessage( cChatColor.Green .. "Usage: /tp [PlayerName] (-h)" )
return true
end
-
- local TeleportDestination = function(OtherPlayer)
- if( OtherPlayer == Player ) then
- Player:SendMessage( cChatColor.Green .. "Already there :)" )
+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)
+ if (OtherPlayer == a_SrcPlayer) then
+ -- Asked to teleport to self?
+ a_SrcPlayer:SendMessage(cChatColor.Green .. "Already there :)");
else
- SetBackCoordinates( Player )
- Player:TeleportToEntity( OtherPlayer )
- Player:SendMessage( cChatColor.Green .. "You teleported to "..OtherPlayer:GetName().."!" )
- if Split[3] ~= "-h" then
- OtherPlayer:SendMessage( cChatColor.Green .. Player:GetName().." teleported to you!" )
+ SetBackCoordinates(a_SrcPlayer);
+ a_SrcPlayer:TeleportToEntity(OtherPlayer);
+ a_SrcPlayer:SendMessage(cChatColor.Green .. "You teleported to " .. OtherPlayer:GetName() .. "!");
+ if (a_TellDst) then
+ OtherPlayer:SendMessage(cChatColor.Green .. Player:GetName().." teleported to you!");
end
end
end
- World = Player:GetWorld()
- if (not(World:DoWithPlayer(Split[2], TeleportDestination))) then
- Player:SendMessage( cChatColor.Green .. "Can't find player " .. Split[2] )
+
+ local World = Player:GetWorld();
+ if (not(World:DoWithPlayer(s_DstPlayerName, teleport))) then
+ a_SrcPlayer:SendMessage(cChatColor.Green .. "Can't find player " .. a_DstPlayerName);
end
- return true
end
+
+
+
+