CreateEntityByName

Last Updated2021-06-24
Created At2007-09-15

Creates an entity by string name, but does not spawn it (see DispatchSpawn). If ForceEdictIndex is not -1, then it will use the edict by that index. If the index is invalid or there is already an edict using that index, it will error out.

native int CreateEntityByName(const char[] classname, int ForceEdictIndex = -1)

Parameters

const char[] classname
Entity classname.
int ForceEdictIndex
Edict index used by the created entity (ignored on Orangebox and above).

Return Value

int Entity index on success, or -1 on failure.

Error

Invalid edict index, no map is running, or lack of mod support.