Added stopped spectating reasons, spectator sometimes stops working for no reason

This commit is contained in:
Logan G 2022-03-26 02:33:12 -06:00
parent f86197d493
commit 236977ba5c
Signed by: logan
GPG key ID: E328528C921E7A7A
2 changed files with 12 additions and 5 deletions

View file

@ -54,6 +54,7 @@ if player() == owner() then do
else
--printHud(Color(250,150,50), "Cannot lock controls, exiting!")
net.start("LSFT-Stop-Spectate")
net.writeString("Cannot lock controls!")
net.send()
return
end
@ -64,8 +65,13 @@ if player() == owner() then do
if not input.isControlLocked() or not target:isValid() or not target:isPlayer() then
--printHud(Color(250,150,50), "Controls are no longer locked, exiting!")
hook.remove("calcview", "freecam")
net.start("LSFT-Stop-Spectate")
if not target:isValid() or not target:isPlayer() then
net.writeString("Invalid target!")
else
net.writeString("")
end
net.send()
return
end
@ -110,6 +116,7 @@ if player() == owner() then do
timer.remove("updateholo")
net.start("LSFT-Stop-Spectate")
net.writeString("")
net.send()
return
end

View file

@ -11,8 +11,8 @@ TODO: Let user open chatbox
do
local function spectate(args)
local function stopSpectate()
core:log(log.INFO, "Stopped spectating.")
local function stopSpectate(reason)
core:log(log.INFO, "Stopped spectating."..(#reason > 0 and "Reason: "..reason or ""))
owner():setViewEntity()
if loadHolo ~= nil then
loadHolo:remove()
@ -22,13 +22,13 @@ do
local loadHolo = nil
net.receive("LSFT-Stop-Spectate", function()
stopSpectate()
stopSpectate(net.readString())
end)
net.receive("LSFT-Teleport-Spectate", function()
local coords = net.readVector()
teleport:tpteleport({coords.x, coords.y, coords.z})
stopSpectate()
stopSpectate("")
end)
net.start("LSFT-Start-Spectate")