Garry's Mod Wiki

SANDBOX:PlayerGiveSWEP

  boolean SANDBOX:PlayerGiveSWEP( Player ply, string weapon, table spawninfo )

Description

Called when a player attempts to give themselves a weapon from the Q menu. (Left mouse clicks on an icon)

Not to be confused with SANDBOX:PlayerSpawnSWEP, which is called when the weapon is spawned as entity on the ground.

Arguments

Returns

1 boolean
Can the SWEP be given to the player

Example

Stops non-admins from giving themselves weapons.

hook.Add( "PlayerGiveSWEP", "BlockPlayerSWEPs", function( ply, class, spawninfo ) if ( not ply:IsAdmin() ) then return false end end )