Garry's Mod Wiki

Revision Difference

GM:PreRegisterSWEP#528924

<cat>hook</cat>⤶ <title>GM:PreRegisterSWEP</title>⤶ ⤶ <function name="PreRegisterSWEP" parent="GM" type="hook">⤶ <ishook>yes</ishook>⤶ <description>⤶ Called by <page>weapons.Register</page>.⤶ </description>⤶ <realm>Shared</realm>⤶ <file line="L48">lua/includes/modules/weapons.lua</file>⤶ <args>⤶ <arg name="swep_table" type="table">The SWEP table to be registered</arg>⤶ <arg name="classname" type="string">The class name to be assigned</arg>⤶ </args>⤶ <rets>⤶ <ret name="" type="boolean">Return `false` to prevent the weapon from being registered. Returning any other value has no effect.</ret>⤶ </rets>⤶ </function>⤶ ⤶ <example>⤶ <description>Prevent registration of any weapon whose name contains a number, and make every other weapon automatic.</description>⤶ <code>⤶ hook.Add( "PreRegisterSWEP", "NoNumbers", function( swep_table, classname )⤶ if string.find(tostring(classname),"%d") then⤶ return false⤶ else⤶ swep_table.Primary.Automatic = true⤶ end⤶ end )⤶ </code>⤶ </example>