Garry's Mod Wiki

WEAPON:AdjustMouseSensitivity

  number WEAPON:AdjustMouseSensitivity( number defaultSensitivity, number localFOV, number defaultFOV )

Description

Allows you to adjust the weapon's mouse sensitivity. This hook only works if you haven't overridden GM:AdjustMouseSensitivity.

Arguments

1 number defaultSensitivity
The old sensitivity

In general this will be 0, which is equivalent to a sensitivity of 1.

2 number localFOV
The player's current FOV.
3 number defaultFOV
The player's default FOV.

Returns

1 number
A multiplier of the player's normal sensitivity (0.5 would be half as sensitive, 2 would be twice as sensitive).

Example

Properly scales the player's sensitivity with their FOV while also halving it.

local ratio = GetConVar("zoom_sensitivity_ratio") function SWEP:AdjustMouseSensitivity(default, localFOV, defaultFOV) if localFOV == defaultFOV then return 0.5 end return (localFOV / defaultFOV) * ratio:GetFloat() * 0.5 end