Garry's Mod Wiki

Player:PickupWeapon

  boolean Player:PickupWeapon( Weapon wep, boolean ammoOnly = false )

Description

Forces the player to pickup an existing weapon entity. The player will not pick up the weapon if they already own a weapon of given type, or if the player could not normally have this weapon in their inventory.

This function will bypass GM:PlayerCanPickupWeapon.

Arguments

1 Weapon wep
The weapon to try to pick up.
2 boolean ammoOnly = false
If set to true, the player will only attempt to pick up the ammo from the weapon. The weapon will not be picked up even if the player doesn't have a weapon of this type, and the weapon will be removed if the player picks up any ammo from it.

Returns

1 boolean result
Whether the player succeeded in picking up the weapon or not.