Garry's Mod Wiki

Garry's Mod Wiki

  WEAPON:Initialize()

Description

Called when the weapon entity is created.

Entity:GetOwner will return NULL at this point because the weapon is not equpped by a player or NPC yet. Use WEAPON:Equip or WEAPON:Deploy if you need the owner to be valid.
This is not called serverside after a quicksave.

Issue Tracker: 3015

Example

Sets the weapon hold type to SWEP.HoldType.

function SWEP:Initialize() self:SetHoldType( self.HoldType ) end

Example

Fixes the function not being called clientside.

function SWEP:Initialize() self.m_bInitialized = true -- Other code end function SWEP:Think() if (not self.m_bInitialized) then self:Initialize() end -- Other code end

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...