Garry's Mod Wiki

Revision Difference

Player:DropWeapon#527731

<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 ) if !IsValid( ply ) then return end⤶ ⤶ -- Loop through all player weapons and drop them⤶ -- Loop through all player weapons and drop them. for i, swep in ipairs( ply:GetWeapons() ) do ply:DropWeapon( swep ) end ⤶ end ) end ) </code> ⤶ </example>⤶ ⤶ ⤶ <example>⤶ </example>⤶ ⤶ <example>⤶ <description>A console command that drops only the currently equipped weapon</description> <code> concommand.Add( "drop_weapon", function( ply ) ⤶ if IsValid(ply) then⤶ ply:DropWeapon() end⤶ ⤶ end )⤶ ply:DropWeapon()⤶ end ) </code> ⤶ </example></example>