CalcView Help

I’m wanting to make a script to simulate the 3rd person in games like Ghost recon and i know i need calc view but am unsure on how to make it where the cross hairs still show where you will shoot.Also i am having trouble turning it on and off.
here’s my code please help me!
[lua]
local on = true
function MyCalcView(ply, origin, angles, fov)
local Origin = origin;
local Angles = angles;
local Fov = fov;

local view = {}
if(on == true)then
view.origin = Origin+angles:Right()*+15+angles:Forward()*-35
view.angles = Angles
view.fov = Fov
else
view.origin = Origin
view.angles = Angles
view.fov = Fov
end
return view

end

hook.Add(“CalcView”, “MyCalcView”, MyCalcView)

hook.Add(“ShouldDrawLocalPlayer”, “MyHax ShouldDrawLocalPlayer”, function(ply)
return true
end)

function setOn()
local on = false
if(on == true)then
on = false
else
on = true
end
end
concommand.Add( “d_setOn”, setOn )
[/lua]

This is for an “Over Shoulder View”, though I think it puts the crosshair in the right place, take a look at it’s code: http://www.garrysmod.org/downloads/?a=view&id=5494

Looked in the code for you, you will need to:
A. Trace the GetShootPos of your LocalPlayer() in the HUDPaint function
B. tr.HitPos:ToScreen() is the real crosshair
C. This is from the Over The Shoulder View code:
[lua]function ThirdPerson.HUDPaint()
local player = LocalPlayer()
if player:GetNetworkedInt(“thirdperson”) == 0 then
return
end

// trace from muzzle to hit pos
local t = {}
t.start = player:GetShootPos()
t.endpos = t.start + player:GetAimVector() * 9000
t.filter = player
local tr = util.TraceLine(t)
local pos = tr.HitPos:ToScreen()
local fraction = math.min((tr.HitPos - t.start):Length(), 1024) / 1024
local size = 10 + 20 * (1.0 - fraction)
local offset = size * 0.5
local offset2 = offset - (size * 0.1)

// trace from camera to hit pos, if blocked, red cursor
t = {}
t.start = player:GetVar("thirdperson_viewpos") or player:GetPos()
t.endpos = tr.HitPos + tr.HitNormal * 5
t.filter = player
local tr = util.TraceLine(t)
if tr.Fraction != 1.0 then
	surface.SetDrawColor(255, 48, 0, 255)
else
	surface.SetDrawColor(255, 208, 64, 255)
end
surface.DrawLine(pos.x - offset, pos.y, pos.x - offset2, pos.y)
surface.DrawLine(pos.x + offset, pos.y, pos.x + offset2, pos.y)
surface.DrawLine(pos.x, pos.y - offset, pos.x, pos.y - offset2)
surface.DrawLine(pos.x, pos.y + offset, pos.x, pos.y + offset2)
surface.DrawLine(pos.x - 1, pos.y, pos.x + 1, pos.y)
surface.DrawLine(pos.x, pos.y - 1, pos.x, pos.y + 1)

end
hook.Add(“HUDPaint”, “ThirdPerson.HUDPaint”, ThirdPerson.HUDPaint)
[/lua]

This may sound stupid but how do i go about doing that?

Well, I posted a bit of code from the download above. You could look at that and use your lua skills(copy -> paste) to put it in your gamemode.

To get on/off working remove local on = false on line 27.