Skip to content

Commit

Permalink
Added /tp [player] [toplayer]
Browse files Browse the repository at this point in the history
Added now because I couldn't add it in #42
  • Loading branch information
tonibm19 committed Jan 19, 2014
1 parent 759cf48 commit 5fe3662
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions console.lua
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,35 @@ function HandleConsoleTeleport(Split)
Player:TeleportToCoords(Split[3], Split[4], Split[5])
end
end

local IsPlayerOnline = false;
local FirstPlayerOnline = false;
local GetPlayerCoords = function(Player)
if (Player:GetName() == Split[3]) then
PosX = Player:GetPosX()
PosY = Player:GetPosY()
PosZ = Player:GetPosZ()
FirstPlayerOnline = true
end
end

local TeleportToPlayer = function(Player)
if (Player:GetName() == Split[2]) then
Player:TeleportToCoords(PosX, PosY, PosZ)
IsPlayerOnline = true
end
end

if #Split == 3 then
return true

cRoot:Get():FindAndDoWithPlayer(Split[3], GetPlayerCoords);
if (FirstPlayerOnline) then
cRoot:Get():FindAndDoWithPlayer(Split[2], TeleportToPlayer);
if (IsPlayerOnline) then
return true, "Teleported " .. Split[2] .." to " .. Split[3]
end
else
return true, "Player " .. Split[3] .." not found"
end
elseif #Split == 5 then
cRoot:Get():FindAndDoWithPlayer(Split[2], TeleportToCoords);
if (IsPlayerOnline) then
Expand Down

0 comments on commit 5fe3662

Please sign in to comment.