--@name --@author --@server --[[ TODO: Draw viewmodel (not possible :c) TODO: Custom HUD (health, armor, etc) --]] do function spectate(args) local loadHolo = nil net.start("LSFT-Start-Spectate") net.receive("LSFT-Stop-Spectate", function() core:log(log.INFO, "Stopped spectating.") owner():setViewEntity() if loadHolo ~= nil then loadHolo:remove() end end) if args[1] == nil then if not holograms.canSpawn() then core:log(log.ERROR, "Cannot spawn hologram for freecam!") end loadHolo = holograms.create(chip():getPos(), Angle(0,0,0), "models/hunter/blocks/cube025x025x025.mdl") loadHolo:setColor(Color(255,255,255,0)) owner():setViewEntity(loadHolo) net.receive("LSFT-LoadHolo-Update", function() loadHolo:setPos(net.readVector()) end) core:log(log.INFO, "Started spectating.") net.send() return end 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 if targets[1]:isPlayer() then core:log(log.INFO, "Started spectating \""..targets[1]:getName().."\".") net.writeEntity(targets[1]) net.send() owner():setViewEntity(targets[1]) end end core.modules.spectate = { version = 1, desc = "Spectate players or freecam.", commands = { spectate = { func = spectate, usage = "spectate [ply]", desc = "Spectate a player in first person by specifying a player, or leave arguments empty for freecam.", }, }, } core.defaultconfig.spectate = { speed = 8, multiplier = 4 } end