WEAPON:PrimaryAttack
WEAPON:PrimaryAttack()
This hook is predicted. This means that in singleplayer, it will not be called in the Client realm.
Description
Called when primary attack button ( +attack ) is pressed.
When in singleplayer, this function is only called in the server realm. When in multiplayer, the hook will be called on both the server and the client in order to allow for Prediction.
You can force the hook to always be called on client like this:
Note that due to prediction, in multiplayer SWEP:PrimaryAttack is called multiple times per one "shot" with the gun. To work around that, use IsFirstTimePredicted.
Example
This is how it is defined in weapon_base