Garry's Mod Wiki

GM:PreRegisterSWEP

  boolean GM:PreRegisterSWEP( table swep, string class )

Description

Called when a Scripted Weapon (SWEP) is about to be registered, allowing addons to alter the weapon's SWEP table with custom data for later usage. Called internally from weapons.Register.

Arguments

1 table swep
The SWEP table to be registered.
2 string class
The class name to be assigned.

Returns

1 boolean
Return false to prevent the weapon from being registered. Returning any other value has no effect.

Example

Prevent registration of any weapon whose name contains a number, additionally, make all weapons automatic.

hook.Add( "PreRegisterSWEP", "NoNumbers", function( swep, class ) if ( string.find( class, "%d" ) ) then return false end swep.Primary.Automatic = true end )