GM:PlayerSwitchWeapon
This hook is predicted. This means that in singleplayer, it will not be called in the Client realm.
Description
Called when a player attempts to switch their weapon.
Primary usage of this hook is to prevent/allow weapon switching, not to detect weapon switching. It will not be called for Player:SetActiveWeapon.
Arguments
2 Weapon oldWeapon
The previous weapon. Will be
NULL
if the previous weapon was removed or the player is switching from nothing.Returns
Example
The players weapon information will be printed when the player switched weapons.
Output: You switched weapons! Your old weapon is gmod_camera.
Your new weapon is weapon_crossbow.