Revision Difference
SANDBOX:PlayerGiveSWEP#562760
<function name="PlayerGiveSWEP" parent="SANDBOX" type="hook">
<file line="902">gamemodes/sandbox/gamemode/commands.lua</file>
<description>Called when a player attempts to give themselves a weapon from the Q menu. ( Left mouse clicks on an icon )</description>⤶
<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 <page>SANDBOX:PlayerSpawnSWEP</page>, which is called when the weapon is spawned as entity on the ground.⤶
</description>⤶
<realm>Server</realm>
<args>
<arg name="ply" type="Player">The player who attempted to give themselves a weapon.</arg>
<arg name="weapon" type="string">Class name of the weapon the player tried to give themselves.</arg>
<arg name="spawninfo" type="table">The weapon list table of this weapon, see https://github.com/Facepunch/garrysmod/blob/c3801c10e1aacc4c114d81331f301c57bdcf5a52/garrysmod/gamemodes/sandbox/gamemode/commands.lua#L893 and https://github.com/Facepunch/garrysmod/blob/c3801c10e1aacc4c114d81331f301c57bdcf5a52/garrysmod/lua/includes/modules/weapons.lua#L58</arg>
</args>
<rets>
<ret name="" type="boolean">Can the SWEP be given to the player</ret>
</rets>
</function>
<example>
<description>Stops non-admins from giving themselves weapons.</description>
<code>
hook.Add( "PlayerGiveSWEP", "BlockPlayerSWEPs", function( ply, class, spawninfo )
if ( not ply:IsAdmin() ) then
return false
end
end )
</code>
</example>