Compare commits

..

No commits in common. "125bcc4fd41046307c09c86bedae7b42712069a2" and "2b0031c683b262aa7a4404af2ff2c58fe41d3385" have entirely different histories.

4 changed files with 8 additions and 172 deletions

View file

@ -17,7 +17,7 @@
TODO: Literally everything TODO: Literally everything
TODO: Update checker TODO: Update checker
TODO: On module load, grab default config values. Write changed values TODO: On module load, grab default config values. Write changed values
TODO: Clientside core:log, with network to owner or server TODO: Clientside core:log, with network to owner
prop.createSent(chip():getPos()+Vector(0,0,90),Angle(0,0,0),"Seat_Airboat",true) prop.createSent(chip():getPos()+Vector(0,0,90),Angle(0,0,0),"Seat_Airboat",true)
--]] --]]

View file

@ -2,11 +2,6 @@
--@author --@author
--@client --@client
--[[
TODO: Clean this up
TODO: Add keybind for teleport
--]]
if player() == owner() then do if player() == owner() then do
net.start("LSFT-Get-Config") net.start("LSFT-Get-Config")
net.writeString("LSFT-Get-Freecam-Binds") net.writeString("LSFT-Get-Freecam-Binds")
@ -70,16 +65,6 @@ if player() == owner() then do
return return
end end
if input.isKeyDown(KEY.R) then
input.lockControls(false)
net.start("LSFT-Teleport-Spectate")
net.writeVector(target:getEyePos())
net.send()
hook.remove("calcview", "freecam")
return
end
return { return {
origin = target:getEyePos(), origin = target:getEyePos(),
angles = target:getEyeAngles(), angles = target:getEyeAngles(),
@ -110,18 +95,6 @@ if player() == owner() then do
return return
end end
if input.isKeyDown(KEY.R) then
input.lockControls(false)
net.start("LSFT-Teleport-Spectate")
net.writeVector(position)
net.send()
hook.remove("calcview", "freecam")
hook.remove("think", "updatepos")
timer.remove("updateholo")
return
end
return { return {
origin = position, origin = position,
angles = eyeAngles(), angles = eyeAngles(),

View file

@ -3,35 +3,24 @@
--@server --@server
--[[ --[[
TODO: Draw viewmodel (not possible :c)
TODO: Custom HUD (health, armor, etc) TODO: Custom HUD (health, armor, etc)
TODO: Grab binds from game instead of settings
TODO: Let user open chatbox
--]] --]]
do do
local function spectate(args) function spectate(args)
local function stopSpectate() local loadHolo = nil
net.start("LSFT-Start-Spectate")
net.receive("LSFT-Stop-Spectate", function()
core:log(log.INFO, "Stopped spectating.") core:log(log.INFO, "Stopped spectating.")
owner():setViewEntity() owner():setViewEntity()
if loadHolo ~= nil then if loadHolo ~= nil then
loadHolo:remove() loadHolo:remove()
end end
end
local loadHolo = nil
net.receive("LSFT-Stop-Spectate", function()
stopSpectate()
end) end)
net.receive("LSFT-Teleport-Spectate", function()
local coords = net.readVector()
teleport:tpteleport({coords.x, coords.y, coords.z})
stopSpectate()
end)
net.start("LSFT-Start-Spectate")
if args[1] == nil then if args[1] == nil then
if not holograms.canSpawn() then if not holograms.canSpawn() then
core:log(log.ERROR, "Cannot spawn hologram for freecam!") core:log(log.ERROR, "Cannot spawn hologram for freecam!")

View file

@ -1,126 +0,0 @@
--@name
--@author
--@server
teleport = {}
do
local function findSafeCoords(coordsin)
local MULTIPLIER = 50 -- How spaced apart the teleport checks are
local CHECKPOINTS = 3 -- How many points to check per axis, MUST BE ODD!
local min = -math.floor(CHECKPOINTS/2)
local max = math.floor(CHECKPOINTS/2)
for x = min,max do
for y = min,max do
for z = min,max do
local teleportcoords = coordsin + Vector(x,y,z)*MULTIPLIER + Vector(0,0,10)
local cornersw = teleportcoords - Vector(17,17,0)
local cornerne = teleportcoords + Vector(17,17,0)
-- TraceHull was being stupid, this is good enough probably
local traceresult = (
trace.trace(cornersw, cornerne+Vector(0,0,90), nil, nil, nil, false).Hit
or
trace.trace(cornerne, cornersw+Vector(0,0,90), nil, nil, nil, false).Hit
)
local testresult = (
trace.pointContents(cornersw) == 1
or
trace.pointContents(cornerne) == 1
or
trace.pointContents(cornersw+Vector(0,0,90)) == 1
or
trace.pointContents(cornerne+Vector(0,0,90)) == 1
or
trace.pointContents(teleportcoords) == 1
)
if not traceresult and not testresult then
--print(trace.pointContents(teleportcoords))
return teleportcoords
--holograms.create(teleportcoords, Angle(0,0,0), "models/hunter/misc/sphere025x025.mdl", Vector(0.5,0.5,0.5)):setColor(Color(0,255,0))
else
--holograms.create(teleportcoords, Angle(0,0,0), "models/hunter/misc/sphere025x025.mdl", Vector(0.5,0.5,0.5)):setColor(Color(255,0,0))
end
end
end
end
return false
end
function teleport:tpteleport(args)
local coords = chip():getPos()
if args[1] ~= nil and args[2] ~= nil and args[3] ~= nil then
coords = Vector(tonumber(args[1]),tonumber(args[2]),tonumber(args[3]))
else
coords = owner():getEyeTrace().HitPos
local offset = Vector(40,40,40)
offset:rotate(owner():getEyeAngles())
coords = coords-offset
end
coords = findSafeCoords(coords)
if not coords then
core:log(log.WARNING, "Could not find a safe position to teleport to!")
return false
end
local seat = prop.createSent(coords, Angle(0,0,0), "Seat_Airboat", true)
seat:setColor(Color(255,255,255,0))
seat:setSolid(false)
seat:use()
seat:remove()
return true
end
function teleport:tpgoto(args)
local targets = find.playersByName(args[1])
if #targets == 0 or targets == nil then
core:log(log.ERROR, "No targets found!")
return
elseif #targets > 1 then
local list = ""
for i, v in pairs(target) do
list = list..v..", "
end
list:sub(1, -2)
core:log(log.ERROR, "Muliple targets found! ("..list..")")
return
end
local targetpos = findSafeCoords(targets[1]:getPos())
local result = teleport:tpteleport({targetpos.x, targetpos.y, targetpos.z})
if result then
core:log(log.INFO, "Successfully teleported to \""..targets[1]:getName().."\".")
end
end
core.modules.teleport = {
version = 1,
desc = "Move player to somewhere else.",
commands = {
goto = {
func = function(args) teleport:tpgoto(args) end, -- Fuck you Lua
usage = "goto <ply>",
desc = "Send yourself to player ply.",
},
teleport = {
func = function(args) teleport:tpteleport(args) end, -- :(
usage = "teleport [x] [y] [z]",
desc = "Send yourself to either your aimpos or the specified coordinates.",
},
},
}
end