Garry's Mod Wiki

Revision Difference

WEAPON:AdjustMouseSensitivity#567605

<function name="AdjustMouseSensitivity" parent="WEAPON" type="hook"> <description>Allows you to adjust the weapon's mouse sensitivity. This hook only works if you haven't overridden <page>GM:AdjustMouseSensitivity</page>.</description> <realm>Client</realm> <args> <arg name="defaultSensitivity" type="number" added="2026.03.12">The old sensitivity In general this will be 0, which is equivalent to a sensitivity of 1.</arg> <arg name="localFOV" type="number" added="2026.03.12">The player's current FOV.</arg> <arg name="defaultFOV" type="number" added="2026.03.12">The player's default FOV.</arg> </args> <rets> <ret name="" type="number">A multiplier of the player's normal sensitivity (0.5 would be half as sensitive, 2 would be twice as sensitive).</ret> </rets> </function> <example> <description>Properly scales the player's sensitivity with their FOV while obeying `zoom_sensitivity_ratio`, mimicking the behavior of the built-in weapons.</description> <description>Properly scales the player's sensitivity with their FOV while obeying `zoom_sensitivity_ratio`, mimicking the behavior of built-in weapons.</description> <code> local ratio = GetConVar("zoom_sensitivity_ratio") function SWEP:AdjustMouseSensitivity(default, localFOV, defaultFOV) if localFOV == defaultFOV then return 1 end return (localFOV / defaultFOV) * ratio:GetFloat() end </code> </example>