diff --git a/modules/client/cl_spectate.txt b/modules/client/cl_spectate.txt index 18ee493..520c0b8 100644 --- a/modules/client/cl_spectate.txt +++ b/modules/client/cl_spectate.txt @@ -2,6 +2,11 @@ --@author --@client +--[[ +TODO: Clean this up +TODO: Add keybind for teleport +--]] + if player() == owner() then do net.start("LSFT-Get-Config") net.writeString("LSFT-Get-Freecam-Binds") @@ -64,6 +69,16 @@ if player() == owner() then do net.send() return 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 { origin = target:getEyePos(), @@ -95,6 +110,18 @@ if player() == owner() then do return 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 { origin = position, angles = eyeAngles(), diff --git a/modules/server/sv_spectate.txt b/modules/server/sv_spectate.txt index cd91d8c..d107a3a 100644 --- a/modules/server/sv_spectate.txt +++ b/modules/server/sv_spectate.txt @@ -3,24 +3,35 @@ --@server --[[ -TODO: Draw viewmodel (not possible :c) TODO: Custom HUD (health, armor, etc) +TODO: Grab binds from game instead of settings +TODO: Let user open chatbox --]] do - function spectate(args) - local loadHolo = nil - - net.start("LSFT-Start-Spectate") - - net.receive("LSFT-Stop-Spectate", function() + local function spectate(args) + local function stopSpectate() core:log(log.INFO, "Stopped spectating.") owner():setViewEntity() if loadHolo ~= nil then loadHolo:remove() end + end + + local loadHolo = nil + + net.receive("LSFT-Stop-Spectate", function() + stopSpectate() 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 not holograms.canSpawn() then core:log(log.ERROR, "Cannot spawn hologram for freecam!")