ENT.Initialize
From GMod Wiki
| Event Hook | |
| Hook Name | Initialize | 
| Syntax | ENT:Initialize( ) | 
| Description | Called right before the entity spawns. | 
| Returns | Nil | 
| Lua State |   | 
| BBCode | [b][url=wiki.garrysmod.com/?title=ENT.Initialize]ENT.Initialize [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] | 
Examples
| Description | Do startup stuff | 
|---|---|
| Used on |  | 
| Code | function ENT:Initialize() self:SetModel("models/dav0r/buttons/button.mdl") end | 
| Output | Sets the model to a button right before spawning. | 
Additional Notes
- This event appears to execute after being spawned, both clientside and serverside. Keep in mind you can do something like this:
| Description | Run code before calling initializer | 
|---|---|
| Used on |  | 
| Code | myEnt=ents.Create("my_ent_type") myEnt:DoStuff("Hi",23,54) myEnt:Spawn() | 
| Output | Does stuff before Initialize is called. | 
myEnt's initialize hook appears to happen right before myEnt:Spawn() is executed. This should allow you to run functions on the entity before initializing if that is necessary.
 
			
			