Garry's Mod Wiki

GM:AllowPlayerPickup

  boolean GM:AllowPlayerPickup( Player ply, Entity ent )

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 GM:GravGunPickupAllowed for the Gravity Gun pickup variant.
See GM:PhysgunPickup for the Physics Gun pickup variant.

Arguments

1 Player ply
The player trying to pick up something.
2 Entity ent
The Entity the player attempted to pick up.

Returns

1 boolean
Allow the player to pick up the entity or not.

Example

Allows only admins to pick up things.

hook.Add( "AllowPlayerPickup", "AllowAdminsPickUp", function( ply, ent ) return ply:IsAdmin() end )