Lua Help: Setting Players to Third Person

I was wondering how would I set it so everyone is third person, and can not switch from third person to first person?

On Client: cycle through the player.GetAll() table, check if the player should be drawn, if not run a console command that sets them to third person.

Elaborate more please.

Ther’s 2 concommands, “thirdperson” which sets him to thirdperson view, and “firstperson” which resets his view.

**[Gamemode.CalcView

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Gamemode.CalcView)**

So I have figured it out. But I am having a few difficulties. It all looks fine, but the problem is the aiming, it is now set to the right of the aimer. If I aim for a headshot it shoots to the right of where I’m aiming, not by much but enough to completely miss. Also when I aim ahead to get it to hit the person. the gun disappears. It shoots but its like I’m holding nothing. Any suggestions please and thankyou.

[lua]function ThirdPerson(ply, pos, angles, fov)
local view = {}
view.origin = pos-(angles:Forward()*100) +
(angles:Right()*50) +
(angles:Up()*20)
view.angles = angles
view.fov = fov

return view

end

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

hook.Add(“ShouldDrawLocalPlayer”, “ShouldDrawLocalPlayer”, function(ply)
return true
end)[/lua]

You have to make your own. you take an eyetraces hit pos and turn it into a screen position[lua]local p = LocalPlayer():GetEyeTrace().HitPos:ToScreen()
local x,y = p.x, p.y[/lua] put that into a HUDPaint hook and draw your crosshairs.

Okay, so the aiming thing, it aims where its supposed to when I am at something other than an enemy or NPC. But not when it comes to aiming at enemies and NPC. You have to aim ahead of those to hit them, and when you do the crosshair snaps to the NPC model.

You can see in the video that I am at the wall and it hits dead on. Then when I aim at the NPC my gun disappears as I am aimed at it, and that I have to aim ahead to shoot it, the crosshair pretty much snaps to it when I do that.

EDIT: If this helps when I remove the EyeAngles(): Right and just have the other two. The aim is accurate, though it still snaps just a tiny bit. Maybe this will help solve my problem if any of you get anything useful from what I just told you.

[lua]function ThirdPerson(ply, pos, angles, fov)
local view = {}
view.origin = ply:GetShootPos() +
(ply:EyeAngles():Right() * 50) +
(Angle(0,ply:EyeAngles().y,0):Forward() * -150) +
(Angle(0,0,ply:EyeAngles().z):Up() * 20)
view.angles = angles
view.fov = fov

 return view

end

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

function GM:HUDPaint( )
local ply = LocalPlayer();
local p = LocalPlayer():GetEyeTrace().HitPos:ToScreen()
local x,y = p.x, p.y

 draw.SimpleText( '+', 'Default', x, y, color_white, 1, 1 )

end[/lua]