Revision Difference
Player:DropWeapon#527732
<function name="DropWeapon" parent="Player" type="classfunc">
<description>Forces the player to drop the specified weapon</description>
<realm>Server</realm>
<args>
<arg name="weapon" type="Weapon" default="nil">Weapon to be dropped. If unset, will default to the currently equipped weapon.</arg>
<arg name="target" type="Vector" default="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.</arg>
<arg name="velocity" type="Vector" default="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.</arg>
</args>
</function>
<example>
<description>A console command that drops all the player's weapons</description>
<code>
concommand.Add( "drop_weapons", function( ply )
-- Loop through all player weapons and drop them.⤶
for i, swep in ipairs( ply:GetWeapons() ) do⤶
ply:DropWeapon( swep )⤶
if ( ply:IsValid() ) then⤶
-- Loop through all player weapons and drop them.⤶
for _, wep in ipairs( ply:GetWeapons() ) do⤶
ply:DropWeapon( wep )⤶
end⤶
end
end )
</code>
</example>
<example>
<description>A console command that drops only the currently equipped weapon</description>
<code>
concommand.Add( "drop_weapon", function( ply )
ply:DropWeapon()⤶
if ( ply:IsValid() ) then⤶
ply:DropWeapon()⤶
end⤶
end )
</code>
</example>