This is a very, very simple add-on to the current teleport functions that will allow you to teleport either yourself or other players back to their last position after you or somebody else has teleported them.
Basically how it works is whenever you or somebody else teleports their position gets saved and can be accessed via a command.
Take the attached file and backup your old teleport.lua located below. (Incase you want to remove this feature.)
/addons/ulx/lua/modules/sh/teleport.lua
This is the command function: Note this will not work without the other things like the table and setting values when somebody teleports.
function ulx.back( calling_ply, target_ply )
if not calling_ply:IsValid() then
Msg( "Cannot run from console.\n" )
return
end
if not target_ply:Alive() then
ULib.tsayError( calling_ply, target_ply:Nick() .. " is dead!", true )
return
end
local newpos = LastPos[ target_ply:SteamID() ]
if not newpos then
ULib.tsayError( calling_ply, "No last position found.", true )
return
end
target_ply:SetPos( LastPos[ target_ply:SteamID() ] )
target_ply:SetLocalVelocity( Vector( 0, 0, 0 ) )
ulx.fancyLogAdmin( calling_ply, "#A teleported #T back to their last position.", target_ply )
end
local back = ulx.command( CATEGORY_NAME, "ulx back", ulx.back, "!back" )
back:addParam{ type = ULib.cmds.PlayerArg, ULib.cmds.optional }
back:defaultAccess( ULib.ACCESS_ADMIN )
back:help( "Teleports you or the selected player back to their last position." )
You must be logged in to view the attached file.