Garry's Mod Wiki

weapons

weapons

The weapons library allows you to access information about any scripted weapons loaded into the game, as well as register your own weapons.

Methods

table weapons.Get( string classname )
Get a copy of weapon table by name. This function also inherits fields from the weapon's base class, unlike weapons.GetStored. This will only work on SWEP's, this means that this will not return anything for HL2 weapons.
table weapons.GetList()
Get a list of all the registered SWEPs. This does not include weapons added to spawnmenu manually.
table weapons.GetStored( string weapon_class )
Gets the REAL weapon table, not a copy. The produced table does not inherit fields from the weapon's base class, unlike weapons.Get. Modifying this table will modify what is stored by the weapons library. Take a copy or use weapons.Get to avoid this.
boolean weapons.IsBasedOn( string name, string base )
Checks if name is based on base
weapons.OnLoaded()
This is used internally - although you're able to use it you probably shouldn't. Called after all SWEPS have been loaded and runs baseclass.Set on each one. You can retrieve all the currently registered SWEPS with weapons.GetList. This is not called after a SWEP auto refresh, and thus the inherited baseclass functions retrieved with baseclass.Get will not be updated
weapons.Register( table swep_table, string classname )
Registers a Scripted Weapon (SWEP) class manually. When the engine spawns an entity, weapons registered with this function will be created if the class names match. See also scripted_ents.Register for Scritped Entities (SENTs) Sub-tables provided in the first argument will not carry over their metatable, and will receive a BaseClass key if the table was merged with the base's. Userdata references, which includes Vectors, Angles, Entities, etc. will not be copied.

Special Pages


Wikis

?

Render Time: 20ms

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