Hey guys, I looked up a Third Person script, this is what came out:
[code]
function MyCalcView(ply, pos, angles, fov)
local view = {}
view.origin = pos-(angles:Forward()*100)
view.angles = angles
view.fov = fov
return view
end
hook.Add("CalcView", "MyCalcView", MyCalcView)
hook.Add("ShouldDrawLocalPlayer", "MyHax ShouldDrawLocalPlayer", function(ply)
return true
end)
[/code]
But, I cant change to firstperson, how would I do this? I would like it to start at firstperson, and then go to thirdperson when you execute a command.
[lua]
hook.Remove("CalcView", "MyCalcView")
hook.Remove("ShouldDrawLocalPlayer", "MyHax ShouldDrawLocalPlayer")
[/lua]
This maybe?
How would I add that in the function? I'm trying the best I can, but I really won't know.
Bump, please do help, I need this for my server.
Second bump :X Please.
Okay. First we make a boolean for whether or not the thirdperson thing is running, and alter the functions slightly so that it doesn't do anything when the boolean is false.
[lua]
local ThirdPersonOn = false
function MyCalcView(ply, pos, angles, fov)
if ThirdPersonOn then
local view = {}
view.origin = pos-(angles:Forward()*100)
view.angles = angles
view.fov = fov
return view
end
end
hook.Add("CalcView", "MyCalcView", MyCalcView)
hook.Add("ShouldDrawLocalPlayer", "MyHax ShouldDrawLocalPlayer", function(ply)
return ThirdPersonOn
end)
[/lua]
The boolean is local, by the way, so it doesn't exist outside this script (where it doesn't need to)
To toggle the boolean with a console command, I'm going to make it turn on if the first argument is 1, anything else will turn it off.
[lua]
local function ThirdPersonToggleCommand (ply, cmd, args)
if args and tonumber(args[1]) == 1 then
ThirdPersonOn = true
else
ThirdPersonOn = false
end
end
concommand.Add("staneh_tperson", ThirdPersonToggleCommand)
[/lua]
Sorry, you need to Log In to post a reply to this thread.