Garry's Mod Wiki

GM:PreRegisterSWEP

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, 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 )

Special Pages


Wikis

?

Render Time: 22ms

DB GetPage 2
Generate Html 5
SaveChanges (1) 5
Render Body 0
Render Sidebar 7