Garry's Mod Wiki


boolean GM:PreRegisterSWEP( table swep, string class )

Just Added

This was just added in the latest version (2021.01.27). It might only be available on the Dev Branch right now.


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, and make every other weapon automatic.

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

Page Links

Special Pages



Render Time: 119ms

DB GetPage 12
Generate Html 11
SaveChanges (1) 77
Render Body 0
Render Sidebar 14