Garry's Mod Wiki

Revision Difference

GM:AllowPlayerPickup#568537

<function name="AllowPlayerPickup" parent="GM" type="hook"> <description> Called when a player tries to pick up something using the "use" key, return to override. This hook will not be called if `sv_playerpickupallowed` is set to 0. See <page>GM:GravGunPickupAllowed</page> for the Gravity Gun pickup variant.<br/> See <page>GM:PhysgunPickup</page> for the Physics Gun pickup variant. ⤶ <note>If this function passes while the Player is holding a Weapon, its <page>Weapon:Holster</page> function will be called next, if such exists.⤶ </note>⤶ </description> <realm>Server</realm> <file line="818-L828">gamemodes/base/gamemode/player.lua</file> <args> <arg name="ply" type="Player">The player trying to pick up something.</arg> <arg name="ent" type="Entity">The Entity the player attempted to pick up.</arg> </args> <rets> <ret name="" type="boolean">Allow the player to pick up the entity or not.</ret> </rets> </function> <example> <description>Allows only admins to pick up things.</description> <code> hook.Add( "AllowPlayerPickup", "AllowAdminsPickUp", function( ply, ent ) if ( !ply:IsAdmin() ) then return false end -- If admin, fallback to default action (allow) and other hooks. end ) </code> </example>