Garry's Mod Wiki

Player:DropWeapon

Player:DropWeapon( Weapon weapon = nil, Vector target = nil, Vector velocity = nil )

Description

Forces the player to drop the specified weapon

Arguments

1 Weapon weapon = nil
Weapon to be dropped. If unset, will default to the currently equipped weapon.
2 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.
3 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.

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 )

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 )

Page Links


Special Pages


Wikis

?

Render Time: 34ms

DB GetPage 4
Generate Html 8
SaveChanges (1) 13
Render Body 0
Render Sidebar 6