Garry's Mod Wiki


  boolean GM:PreRegisterSWEP( table swep, string class )


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.


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


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


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 )