I made a little script i thought would be useful, and havoc told me to post it here so i did.
Feel free to use it but give credit where possible please.
If running on a normal server, place script in autorun/server and it will work fine. If running it with a gamemode see below
Put it in the Gamemodename/gamemode folder to run it with a gamemode, but make sure when doing that to add this to init.lua
include("scriptname.lua") -- scriptname.lua being the name of the script.
function StartSpectate(ply,cmd,args) if ply:IsAdmin() then for k,v in ipairs(player.GetAll()) do if string.find(v:Nick(),args) then local play=v ply:Spectate( 4 ) ply:SpectateEntity( play ) ply:ChatPrint("You are now spectating "..play:Nick()) end end end end function un_spectate(ply) if ply:IsAdmin() then ply:UnSpectate() end end concommand.Add("Spectate_Player",StartSpectate) concommand.Add("Spectate_Off",un_spectate)
To use the script, console commands are:
Spectate_Player name - Puts you into first person of a player.
Spectate_Off - Turns spectating off.
This code may be inefficient, it is my first attempt on the subject. Please post any improvements below & give credit.