SWEP.Initialize
From GMod Wiki
| Event Hook | |
| Hook Name | Initialize |
| Syntax | SWEP:Initialize( ) |
| Description | Called when the weapon entity is created. |
| Returns | Nil |
| Lua State | |
| BBCode | [b][url=wiki.garrysmod.com/?title=SWEP.Initialize]SWEP.Initialize [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Example
| Description | Setting up values when the weapon is initialized. |
|---|---|
| Used on | |
| Code | function SWEP:Initialize() self:SetWeaponHoldType( self.HoldType ) self:SetNetworkedBool( "Ironsights", false ) end |
| Output | N/A |
Additional Notes
- This is called BEFORE you pull the weapon out, meaning self.Owner does not exist.
- This code was pulled from the Counter-Strike Source base file.