Player/DropWeapon

From Garry's Mod
Jump to: navigation, search
 Player:DropWeapon( )

Contents

Description

Forces the player to drop the specified weapon

Arguments

Weapon weapon=nil

Weapon to be dropped. If unset, will default to the currently equipped weapon.

Arguments

Vector target=nil

If set, launches the weapon at given position. There is a limit to how far it is willing to throw the weapon. Overrides velocity argument.

Arguments

Vector velocity=nil

If set and previous argument is unset, launches the weapon with given velocity. If the velocity is higher than 400, it will be clamped to 400.

Examples

Example

A console command that drops all the player's weapons

concommand.Add( "drop_weapons", function( ply )
	if ( !IsValid( ply ) ) then return end

	-- Loop through all player weapons and drop them
	for k, v in pairs( ply:GetWeapons() ) do
		ply:DropWeapon( v )
	end
end )


Examples

Example

A console command that drops only the currently equipped weapon

concommand.Add( "drop_weapon", function( ply )
	if ( !IsValid( ply ) ) then return end

	-- Dtop the currently equipped weapon
	ply:DropWeapon( ply:GetActiveWeapon() )
end )


Personal tools
Navigation