ents/Create

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Stupid code highlighter replicating stuff in comments!)
m (Warning template)
Line 1: Line 1:
 
{{Func
 
{{Func
|Name=Create
 
|Parent=ents
 
 
|Description=Starts creating an entity.
 
|Description=Starts creating an entity.
  
'''WARNING''': Do not use before {{HookFunction|GM|InitPostEntity}} has been called, otherwise the server will crash!<br>If you need to perform entity creation when the game starts, create a hook for {{HookFunction|GM|InitPostEntity}} and do it there!
+
{{Warning|Do not use before {{HookFunction|GM|InitPostEntity}} has been called, otherwise the server will crash!<br>If you need to perform entity creation when the game starts, create a hook for {{HookFunction|GM|InitPostEntity}} and do it there}}
 
|Realm=Server
 
|Realm=Server
 
|IsClass=No
 
|IsClass=No
 +
|Name=Create
 +
|Parent=ents
 
}}
 
}}
 
{{Arg
 
{{Arg

Revision as of 09:41, 23 August 2016

 ents.Create( )

Contents

Description

Starts creating an entity.

WARNING

Do not use before GM:InitPostEntity has been called, otherwise the server will crash!
If you need to perform entity creation when the game starts, create a hook for GM:InitPostEntity and do it there

Arguments

string class

The classname of the entity to create

Returns

Entity

The created entity

Examples

Example

Creates a gmod_button entity near 0,0,0

local button = ents.Create( "gmod_button" )
if ( !IsValid( button ) ) then return end // Check whether we successfully made an entity, if not - bail
button:SetModel( "models/dav0r/buttons/button.mdl" )
button:SetPos( Vector( 0, 0, 100 ) )
button:Spawn()


Personal tools
Navigation