Javascript required
Skip to content Skip to sidebar Skip to footer

How to Go Into Third Person in Gmod

  1. 05-04-2017 #1

    Simple Clientside Thirdperson

    So I was adding this to my script and my friend didn't understand how I did it, and it got me thinking "What if a LOT of people didn't understand it?" so I decided to release my 3rd person script..ENJOY!

    Code:

    CreateClientConVar(rook.."ThirdPerson", 0, true, false) hook.Add( "CalcView", "ThirdPerson", function(ply, pos, angles, fov) 	local ThirdPerson = {} 	if GetConVarNumber("ThirdPerson") == 1 then 	ThirdPerson.origin = pos-( angles:Forward()*100 ) 	ThirdPerson.angles = angles 	ThirdPerson.fov = fov 	ThirdPerson.drawviewer = true 	return ThirdPerson 	elseif GetConVarNumber(rook.."ThirdPerson") == 0 then 	ThirdPerson.origin = pos-( angles:Forward() ) 	ThirdPerson.angles = angles 	ThirdPerson.fov = fov 	end end)

  2. 05-04-2017 #2

    dude why are you releasing all this dumb shit literally everyone knows how to do it
    this code is awful anyways

    Code:

    CreateClientConVar(rook.."ThirdPerson", 0, true, false) hook.Add( "CalcView", "ThirdPerson", function(ply, pos, angles, fov) 	local ThirdPerson = {} 	if GetConVarNumber("ThirdPerson") == 1 then 	ThirdPerson.origin = pos-( angles:Forward()*100 ) 	ThirdPerson.angles = angles 	ThirdPerson.fov = fov 	ThirdPerson.drawviewer = true 	return ThirdPerson 	elseif GetConVarNumber(rook.."ThirdPerson") == 0 then 	ThirdPerson.origin = pos-( angles:Forward() ) 	ThirdPerson.angles = angles 	ThirdPerson.fov = fov 	end end)
    can be shortened to

    Code:

    CreateClientConVar(ThirdPerson", 0, true, false) hook.Add( "CalcView", "ThirdPerson", function(ply, pos, angles, fov) 	local ThirdPerson = {} 	ThirdPerson.origin = (GetConVarNumber("ThirdPerson") == 1) and (pos-(angles:Forward()*100)) or pos 	ThirdPerson.angles = angles 	ThirdPerson.fov = fov 	ThirdPerson.drawviewer = GetConVarNumber("ThirdPerson") == 1 	return ThirdPerson end)
    Last edited by too much sauce; 05-04-2017 at 10:33 PM.

  3. 05-05-2017 #3

    Quote Originally Posted by too much sauce View Post

    dude why are you releasing all this dumb shit literally everyone knows how to do it
    this code is awful anyways

    Code:

    CreateClientConVar(rook.."ThirdPerson", 0, true, false) hook.Add( "CalcView", "ThirdPerson", function(ply, pos, angles, fov) 	local ThirdPerson = {} 	if GetConVarNumber("ThirdPerson") == 1 then 	ThirdPerson.origin = pos-( angles:Forward()*100 ) 	ThirdPerson.angles = angles 	ThirdPerson.fov = fov 	ThirdPerson.drawviewer = true 	return ThirdPerson 	elseif GetConVarNumber(rook.."ThirdPerson") == 0 then 	ThirdPerson.origin = pos-( angles:Forward() ) 	ThirdPerson.angles = angles 	ThirdPerson.fov = fov 	end end)

    can be shortened to

    Code:

    CreateClientConVar(ThirdPerson", 0, true, false) hook.Add( "CalcView", "ThirdPerson", function(ply, pos, angles, fov) 	local ThirdPerson = {} 	ThirdPerson.origin = (GetConVarNumber("ThirdPerson") == 1) and (pos-(angles:Forward()*100)) or pos 	ThirdPerson.angles = angles 	ThirdPerson.fov = fov 	ThirdPerson.drawviewer = GetConVarNumber("ThirdPerson") == 1 	return ThirdPerson end)
    or if you do it properly it'll look like

    Code:

    local tp = CreateClientConVar("_thirdperson", "0")  local Thirdperson = function(ply, origin, angles) 	local view = {} 	local active = tp:GetBool()  	view.origin = active and origin - (angles:Forward() * 100) or origin 	view.drawviewer = active  	return view end hook.Add("CalcView", "Thirdperson", Thirdperson)

  4. 05-05-2017 #4

    Quote Originally Posted by Cyaegha View Post

    or if you do it properly it'll look like

    Code:

    local tp = CreateClientConVar("_thirdperson", "0")  local Thirdperson = function(ply, origin, angles) 	local view = {} 	local active = tp:GetBool()  	view.origin = active and origin - (angles:Forward() * 100) or origin 	view.drawviewer = active  	return view end hook.Add("CalcView", "Thirdperson", Thirdperson)
    Hmm.. smart! I released mine just because nobody really had any info on it and I just didn't want people C+Ping from random cheats or something. I got mine to work that way, and I can't stress enough that I am new to GLua, and I thought it was quite an accomplishment. Use it or not, it's for the people who didn't get theirs working or need one. I looked greatly into the ways you've done yours and I still prefer my way since it is mine, however I will try to learn from the ways you've done it. Thanks for expanding my idea!

  5. 05-05-2017 #5

    Nice men

  6. The Following User Says Thank You to oxcraftboys For This Useful Post:

    JayFromSubway (05-06-2017)

  7. 05-05-2017 #6

    Nice work men <3

  8. The Following User Says Thank You to HUNDER. For This Useful Post:

    JayFromSubway (05-06-2017)

  9. 05-08-2017 #7

    Quote Originally Posted by JayFromSubway View Post

    I just didn't want people C+Ping from random cheats or something

    and now they'll c+p from random posts on mpgh, what's the difference

  10. The Following User Says Thank You to mavvsy For This Useful Post:


How to Go Into Third Person in Gmod

Source: https://www.mpgh.net/forum/showthread.php?t=1255315