Garry's Mod Wiki

ents.Create

Entity ents.Create( string class )

Description

Creates an entity. This function will fail and return NULL if the networked-edict limit is hit (around 8176), or the provided entity class doesn't exist.

Do not use before 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 GM:InitPostEntity and do it there.

Arguments

1 string class
The classname of the entity to create

Returns

1 Entity
The created entity, or NULL if failed

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()

Page Links


Special Pages


Wikis

?

Render Time: 40ms

Session 0
DB GetPage 3
Generate Html 16
SaveChanges 8
Render Body 0
Render Sidebar 11