Garry's Mod Wiki

ents.Create

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! 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 Vector(0, 0, 0).

local button = ents.Create( "gmod_button" ) button:SetModel( "models/dav0r/buttons/button.mdl" ) button:SetPos( Vector( 0, 0, 100 ) ) button:Spawn()

Special Pages


Wikis

?

Render Time: 31ms

DB GetPage 4
Generate Html 4
SaveChanges (1) 15
Render Body 0
Render Sidebar 6