ENT.SpawnFunction

From GMod Wiki

Revision as of 06:05, 10 February 2011 by Grune (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Event Hook
Hook NameSpawnFunction
SyntaxENT:SpawnFunction( Player Player, Structure Trace )
DescriptionCalled when a player presses the button in the spawn menu to spawn this SENT in the Sandbox gamemode.
In here you should create your entity using ents.Create() and spawn it inside the world.
ReturnsNil
Lua StateNewerServer.png
BBCode[b][url=wiki.garrysmod.com/?title=ENT.SpawnFunction]ENT.SpawnFunction [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionSpawns a SENT and activates it and all.
Used onNewerServer.png
Code
function ENT:SpawnFunction( ply, tr )
    if ( !tr.Hit ) then return end
    local ent = ents.Create( self.Classname )
    ent:SetPos( tr.HitPos + tr.HitNormal * 16 ) 
    ent:Spawn()
    ent:Activate()
 
    return ent
end
OutputN/A


Additional Notes

local ent = scripted_ents.GetStored(EntName)
ent.t:SpawnFunction(ply, tr)

That will spawn the requested entity, running the SpawnFunction function.

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox