TP function

How do i make a tp function that checks where its possible to tp so the person dont gets stuck in world or a prop?
I know how to make a tp function i just need to know how to make so the person dont gets stuck in world or a prop.

[lua]
function Plugin.Command( ply, cmd, args )
if !SAdmin.HasAccess( ply, Plugin.CC ) then
return
end
if !ply:IsValid() then
SAdmin.SendMsg( ply, “You are the Console, you cannot do that.”)
return
end
local plf = SAdmin.PlayerFind( ply, args[1] )
if plf then
for k, v in pairs( plf ) do
local trace = {}
trace.start = ply:GetShootPos()
trace.endpos = ply:GetShootPos() + ply:GetAimVector() * 99999
trace.filter = ply
local tr = util.TraceLine( trace )
v:SetPos( tr.HitPos - ply:GetAimVector( ) * 50 + Vector( 0, 0, 15 ) )
end
if #plf == #player.GetAll() and #plf > 1 then
SAdmin.Notify( ply:Nick() … Plugin.Verb … "everyone to position " … tostring( plf[1]:GetPos() ) )
else
local names = {}
for k, v in pairs( plf ) do
local v = v:Nick()
if ply:IsValid() then
if v == ply:Nick() then
v = “himself”
end
end
table.insert( names, v )
end
SAdmin.Notify( ply, Plugin.Verb … table.concat( names, ", " ) … " to position " … tostring( plf[1]:GetPos() ) )
end
end
end
SAdmin.AddPlugin( Plugin )
[/lua]

thanks will try it