• Spectating Script (Admins spectate players)
    4 replies, posted
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 [code] include("scriptname.lua") -- scriptname.lua being the name of the script. [/code] [code] function StartSpectate(ply,cmd,args) if ply:IsAdmin() then for k,v in ipairs(player.GetAll()) do if string.find(v:Nick(),args[1]) 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) [/code] 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.
You're setting play to nil, but play is a local variable in a different scope.
Ah ok, thanks, can you see anything else wrong?
Why did you remove it?
Read post above
Sorry, you need to Log In to post a reply to this thread.