Garry's Mod Wiki

Revision Difference

SANDBOX:PlayerSpawnSWEP#562759

<function name="PlayerSpawnSWEP" parent="SANDBOX" type="hook"> <description>Called when a player attempts to spawn a weapon from the Q menu. ( Mouse wheel clicks on an icon )</description>⤶ <description>Called when a player attempts to spawn a weapon from the Q menu as an entity on the ground. (Mouse wheel clicks on an icon)⤶ ⤶ Not to be confused with <page>SANDBOX:PlayerGiveSWEP</page>, which is called only when the weapon is given to the player directly, if they don't already have it.</description>⤶ <realm>Server</realm> <args> <arg name="ply" type="Player">The player who attempted to spawn a weapon.</arg> <arg name="weapon" type="string">Class name of the weapon the player tried to spawn.</arg> <arg name="swep" type="table">Information about the weapon the player is trying to spawn, see <page>Structures/SWEP</page></arg> </args> <rets> <ret name="" type="boolean">Can the SWEP be spawned</ret> </rets> </function> <example> <description>Stops non-admins from spawning weapons.</description> <code> hook.Add( "PlayerSpawnSWEP", "SpawnBlockSWEP", function( ply, class, info ) if ( not ply:IsAdmin() ) then return false end end ) </code> </example>