Spectate can now teleport to current position by hitting R
This commit is contained in:
parent
e3aad2621a
commit
c0a09101ab
2 changed files with 45 additions and 7 deletions
|
@ -2,6 +2,11 @@
|
||||||
--@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")
|
||||||
|
@ -64,6 +69,16 @@ if player() == owner() then do
|
||||||
net.send()
|
net.send()
|
||||||
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(),
|
||||||
|
@ -95,6 +110,18 @@ 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(),
|
||||||
|
|
|
@ -3,24 +3,35 @@
|
||||||
--@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
|
||||||
function spectate(args)
|
local function spectate(args)
|
||||||
local loadHolo = nil
|
local function stopSpectate()
|
||||||
|
|
||||||
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!")
|
||||||
|
|
Loading…
Reference in a new issue