F4 third person

Can’t be too hard can it?

Lead in the right direction or where to start.

Thanks!

PlayerBindPress or monitor keys with other hooks. The 4 server-side hooks for the F1-4 keys are
– GM:ShowHelp --F1
– GM:ShowTeam --F2
– GM:ShowSpare1 --F3
– GM:ShowSpare2 --F4

Hook into CalcView, if it’s thirdperson then change view.drawviewer to true to render yourself, then adjust the camera based on where you want it. Look into using Normalized Vectors; example if you want the camera to be 100 units behind you, you can take the player angle and turn it into a normalized vector using a custom function, or angle:Forward( ) * -100

Next, test for collisions with a wall so the camera doesn’t go through walls and if tr.Hit then use tr.HitPos as the new origin instead of the LocalPlayer( ):GetAngles( ):Forward( ) * -100


if SERVER then
	hook.Add( "ShowSpare2", "ToggleThirdperson", function(ply)
		ply:ConCommand("zombie_thirdperson")
	end )
end

if CLIENT then

	local function ThirdPerson(ply, pos, angles, fov)
		if ( LocalPlayer()._inThirdPerson ) and LocalPlayer():Alive() then
			local view = {}
			view.origin = pos-(angles:Forward()*150) +
									(angles:Right()*1) +
											(angles:Up()*8)
				view.angles = angles
				view.fov = fov
		 
			return view
		end
	end
	hook.Add("CalcView", "ThirdPerson", ThirdPerson)
	hook.Add("ShouldDrawLocalPlayer", "ThirdPersonShouldDrawLocalPlayer", function()
		return (LocalPlayer()._inThirdPerson == true)
	end)

	concommand.Add("zombie_thirdperson", function()
		if LocalPlayer()._inThirdPerson == nil then
			LocalPlayer()._inThirdPerson = false
		end
		LocalPlayer()._inThirdPerson = not LocalPlayer()._inThirdPerson
		return
	end)
	
end

Put that in autorun

MrPlonker question where did u get this idea? i have the same thing i made on my servers i guess i might release it in my Pointshop scripts but not my taunt system.

You don’t need to hook into ShouldDrawLocalPlayer - just set view.drawviewer to true in the CalcView hook; additionally test for collisions with walls or you’ll clip through walls meaning players will be able to see through walls…

Wait my bad u dont want it for pointshop do you mine is for pointshop although i could make it without ps

Thanks!

Its for a bhop server btw nothing too exclusive.

Oh ok great :stuck_out_tongue: Good Luck to you and your community

I think I know who he is… CosmosServers?

Also mark as solved :stuck_out_tongue:

Nope none of the above but thanks everyone for your input

/solved

The Mark-As-Solved button is in the top-left corner!