player.SetFOV

From GMod Wiki

Jump to: navigation, search
Function
Syntax player.SetFOV( Integer fov, Float time )
Description:
Sets player's FOV in time.
Returns: nil
In Object: Player
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Player.SetFOV]Player.SetFOV [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionAlternate between zoom when the player uses a SWEP's secondary fire.
Used onNewerShared.png
Code
 -- Secondary Attack (+Attack2 is pressed)
function SWEP:SecondaryAttack()
	-- We have already defined Zoomed as being false.
	if (!Zoomed) then -- The player is not zoomed in
 
		Zoomed = true -- Now he is
		if SERVER then
			self.Owner:SetFOV( 45, 0.3 ) -- SetFOV is serverside only
		end
	else -- If he is
 
		Zoomed = false -- We tell the SWEP that he is not
		if SERVER then
			self.Owner:SetFOV( 0, 0.3 ) -- Setting to 0 resets the FOV
		end
	end
end
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox