ents.Create

From GMod Wiki

Revision as of 22:21, 16 May 2010 by Crazy Quebecer (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax ents.Create( String entity class )
Where is this used?
Description:
Create the specified entity.
Returns: Entity
Part of Library: Ents
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Ents.Create]Ents.Create [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Example

DescriptionThis example spawns an angry zombie in front of the first player in the server (Usually you!).
Used onNewerServer.png
Code
local ply = Entity(1) -- The first entity is always the first player
local tr = ply:GetEyeTrace() -- tr now contains a trace object
local ent = ents.Create("npc_zombie") -- This creates our zombie entity
ent:SetPos(tr.HitPos) -- This positions the zombie at the place our trace hit.
ent:Spawn() -- This method spawns the zombie into the world, run for your lives! ( or just crowbar it dead(er) )
OutputEntity


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox